Anonymous | Login | 2024-09-07 13:55 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 | ||
0001129 | [1003.1(2016/18)/Issue7+TC2] Shell and Utilities | Objection | Error | 2017-03-21 14:32 | 2024-06-11 09:09 | ||
Reporter | McDutchie | View Status | public | ||||
Assigned To | |||||||
Priority | normal | Resolution | Accepted | ||||
Status | Closed | ||||||
Name | Martijn Dekker | ||||||
Organization | modernish | ||||||
User Reference | |||||||
Section | C.2.5 | ||||||
Page Number | 3724 | ||||||
Line Number | 127689-127690 | ||||||
Interp Status | --- | ||||||
Final Accepted Text | |||||||
Summary | 0001129: Incorrect example output of IFS=''; unset var; printf '%s\n' ${var-$*} | ||||||
Description |
According to the specification (2.5.2 Special Parameters), given null IFS and unset 'var', the output of printf '%s\n' ${var-$*} should be: abc def ghi jkl and not abcdef ghijkl Reasoning: First, given an unset 'var', unquoted $* and unquoted ${var-$*} (and unquoted ${1+$*}, etc) should act identically. If they don't, that's a bug either way. Second, the cited example is contrary to the specification, which says: "Expands to the positional parameters, starting from one, initially producing one field for each positional parameter that is set. When the expansion occurs in a context where field splitting will be performed, any empty fields may be discarded and each of the non-empty fields shall be further split as described in Field Splitting. [...]" Well, the expansion occurs "in a context where field splitting will be performed" because it is unquoted (the fact that IFS happens to be null is neither here nor there; its value or lack thereof has no bearing on the lexical context). So the non-empty fields, having been generated, "shall be further split as described in Field Splitting", which, given that IFS is null, is a no-op. In other words, quoted "$*" should join the fields into one, but (given null IFS) unquoted $* should leave the fields alone altogether. In other words again, unquoted $* should act identically to unquoted $@, hence, unquoted ${var-$*}, ${1+$*}, etc. should act identically to unquoted ${var-$@}, ${1+$@}, etc. (Note that the case of a default assignment using a parameter substitution, e.g. ${var=$*} given unset 'var', is different; 2.6.2 Parameter Expansion explicitly states for ${parameter:=[word]} that "in all cases, the final value of /parameter/ shall be substituted". So the example in lines 127695-127696 is correct.) |
||||||
Desired Action |
Change the example in lines 127689-127690 to: printf '%s\n' ${var-$*} abc def ghi jkl |
||||||
Tags | tc3-2008 | ||||||
Attached Files | |||||||
|
Notes | |
(0003646) geoffclare (manager) 2017-03-21 15:17 |
My response on the mailing list was: Good catch. I agree, we got that case wrong in the examples. |
Mantis 1.1.6[^] Copyright © 2000 - 2008 Mantis Group |