View Issue Details
ID | Project | Category | View Status | Date Submitted | Last Update |
---|---|---|---|---|---|
0000941 | 1003.1(2013)/Issue7+TC1 | Shell and Utilities | public | 2015-04-28 21:31 | 2019-06-15 06:56 |
Reporter | stephane | Assigned To | |||
Priority | normal | Severity | Editorial | Type | Error |
Status | Closed | Resolution | Accepted As Marked | ||
Name | Stephane Chazelas | ||||
Organization | |||||
User Reference | |||||
Section | locale | ||||
Page Number | 2872 | ||||
Line Number | 94572 | ||||
Interp Status | --- | ||||
Final Accepted Text | See 0000941: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 |
|
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 |
|
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 ;)) |
|
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 ;-). |
|
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)") |
|
Re: 0000941: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 0000941: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 |