Austin Group Defect Tracker

Aardvark Mark IV


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 2019-10-31 11:35
Reporter McDutchie View Status public  
Assigned To
Priority normal Resolution Accepted  
Status Applied  
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

- Relationships

-  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.

- Issue History
Date Modified Username Field Change
2017-03-21 14:32 McDutchie New Issue
2017-03-21 14:32 McDutchie Name => Martijn Dekker
2017-03-21 14:32 McDutchie Organization => modernish
2017-03-21 14:32 McDutchie Section => C.2.5
2017-03-21 14:32 McDutchie Page Number => 3724
2017-03-21 14:32 McDutchie Line Number => 127689-127690
2017-03-21 15:17 geoffclare Note Added: 0003646
2017-03-22 11:50 geoffclare Note View State: public: 3646
2018-08-30 16:21 Don Cragun Interp Status => ---
2018-08-30 16:21 Don Cragun Resolution Open => Accepted
2018-08-30 16:21 Don Cragun Tag Attached: tc3-2008
2018-08-30 16:22 Don Cragun Status New => Resolved
2019-10-31 11:35 geoffclare Status Resolved => Applied


Mantis 1.1.6[^]
Copyright © 2000 - 2008 Mantis Group
Powered by Mantis Bugtracker