Anonymous | Login | 2023-10-02 01:19 UTC |
Main | My View | View Issues | Change Log | Docs |
Viewing Issue Simple Details [ Jump to Notes ] | [ Issue History ] [ Print ] | ||||||
ID | Category | Severity | Type | Date Submitted | Last Update | ||
0000941 | [1003.1(2013)/Issue7+TC1] Shell and Utilities | Editorial | Error | 2015-04-28 21:31 | 2019-06-15 06:56 | ||
Reporter | stephane | View Status | public | ||||
Assigned To | |||||||
Priority | normal | Resolution | Accepted As Marked | ||||
Status | Closed | ||||||
Name | Stephane Chazelas | ||||||
Organization | |||||||
User Reference | |||||||
Section | locale | ||||||
Page Number | 2872 | ||||||
Line Number | 94572 | ||||||
Interp Status | --- | ||||||
Final Accepted Text | See Note: 0002706 | ||||||
Summary | 0000941: Unreliable example using "locale yesexpr" | ||||||
Description |
The example there has: if printf "%s\n" "$response" | grep -Eq "$(locale yesexpr)" then affirmative processing goes here else non-affirmative processing goes here fi However, there are three problems with that at least: - That returns true if yesexpr matches any of the lines in $response, not $response as a whole - That fails if yesexpr starts with - (unlikely in practice) - That fails if yesexpr ends in newline characters (unlikely in practice) |
||||||
Desired Action |
A more correct example (still doesn't address point 3) may be: if awk 'BEGIN{exit(!(ARGV[1] ~ ARGV[2]))}' "$response" "$(locale yesexpr)" ... |
||||||
Tags | tc2-2008 | ||||||
Attached Files | |||||||
|
![]() |
|
(0002706) nick (manager) 2015-06-11 15:19 |
Update example on page 2872, lines 94572-94577 to:printf 'Prompt for response: ' read response if printf "%s\n" "$response" | grep −Eq -- "$(locale yesexpr)" then affirmative processing goes here else non-affirmative processing goes here fi |
(0002707) stephane (reporter) 2015-06-11 15:41 |
Thanks Nick. That does address points 1 and 2 and clarifies that the response being checked is one-line. Where it may be improved is that in a locale where yesexpr is ^[yY].* for instance, that would return affirmative for an input like " \y" because of the extra processing done by "read" by default. IFS= read -r response would probably be more correct, though leaving out the "IFS=" part may be considered as a feature (ignore leading and trailing unescaped space characters, but then again there may be locales where space means yes ;)) |
(0002708) stephane (reporter) 2015-06-11 15:57 |
One could also argue that issuing a prompt in the English language and expecting an answer in the user's language is not the best design ;-). |
(0004424) stephane (reporter) 2019-06-14 21:36 |
Looking at the 2018 edition line 96034, it seems the fix for this bug has not been applied properly. It reads: grep -- -Eq "$(locale yesexpr)" Instead of: grep -Eq -- "$(locale yesexpr)" (or grep -Eqe "$(locale yesexpr)") |
(0004426) geoffclare (manager) 2019-06-15 06:55 |
Re: Note: 0004424 You are correct, but this is not the right place to report your observation. This bug references Issue7+TC1 which does not have the problem you observed. You should submit a new bug against the version of the standard that has the new problem, i.e. Issue7+TC2. |
![]() |
|||
Date Modified | Username | Field | Change |
2015-04-28 21:31 | stephane | New Issue | |
2015-04-28 21:31 | stephane | Name | => Stephane Chazelas |
2015-04-28 21:31 | stephane | Section | => http://pubs.opengroup.org/onlinepubs/9699919799/utilities/locale.html [^] |
2015-04-28 21:31 | stephane | Page Number | => http://pubs.opengroup.org/onlinepubs/9699919799/utilities/locale.html#tag_20_68_17 [^] |
2015-04-28 21:31 | stephane | Line Number | => http://pubs.opengroup.org/onlinepubs/9699919799/utilities/locale.html#tag_20_68_17 [^] |
2015-06-11 15:19 | nick | Note Added: 0002706 | |
2015-06-11 15:21 | nick | Section | http://pubs.opengroup.org/onlinepubs/9699919799/utilities/locale.html [^] => locale |
2015-06-11 15:21 | nick | Page Number | http://pubs.opengroup.org/onlinepubs/9699919799/utilities/locale.html#tag_20_68_17 [^] => 2872 |
2015-06-11 15:21 | nick | Line Number | http://pubs.opengroup.org/onlinepubs/9699919799/utilities/locale.html#tag_20_68_17 [^] => 94572 |
2015-06-11 15:21 | nick | Interp Status | => --- |
2015-06-11 15:21 | nick | Final Accepted Text | => See Note: 0002706 |
2015-06-11 15:21 | nick | Status | New => Resolved |
2015-06-11 15:21 | nick | Resolution | Open => Accepted As Marked |
2015-06-11 15:21 | nick | Tag Attached: tc2-2008 | |
2015-06-11 15:41 | stephane | Note Added: 0002707 | |
2015-06-11 15:57 | stephane | Note Added: 0002708 | |
2019-06-10 08:54 | agadmin | Status | Resolved => Closed |
2019-06-14 21:36 | stephane | Note Added: 0004424 | |
2019-06-14 21:36 | stephane | Status | Closed => Under Review |
2019-06-14 21:36 | stephane | Resolution | Accepted As Marked => Reopened |
2019-06-15 06:55 | geoffclare | Note Added: 0004426 | |
2019-06-15 06:55 | geoffclare | Status | Under Review => Closed |
2019-06-15 06:56 | geoffclare | Resolution | Reopened => Accepted As Marked |
Mantis 1.1.6[^] Copyright © 2000 - 2008 Mantis Group |