View Issue Details

IDProjectCategoryView StatusLast Update
00008321003.1(2013)/Issue7+TC1Shell and Utilitiespublic2019-06-10 08:54
Reporterormaaj Assigned Toajosey  
PrioritynormalSeverityObjectionTypeClarification Requested
Status ClosedResolutionAccepted As Marked 
NameDan Douglas
Organization
User Reference
Section2.6.5
Page Number2333
Line Number74133
Interp StatusApproved
Final Accepted TextSee 0000832:0002220.
Summary0000832: Clarify whether field splitting applies to arithmetic expansion
DescriptionThe first paragraph of section 2.6.5 states that after parameter expansion, command substitution, and arithmetic expansion, field splitting should apply to unquoted expansions and substitutions. That sentence could be interpreted as either referring to arithmetic expansion only with regards to the order of operations, or to imply that field splitting should apply to the results.

The subsequent sentence beginning on line 74136 then refers only to parameter expansion and command substitution without being explicit about whether that should exclude arithmetic expansion.

Many but not all current implementations do appear to apply field splitting to the results of arithmetic expansion per the following testcase:

    #!/bin/sh
    
    code='${ZSH_VERSION+false} || emulate sh
    ${BASH_VERSION+set -o posix}
    
    IFS=0
    printf "<%s> " $((1230456))'
    
    for sh in bash zsh ksh mksh posh dash bb; do
        printf '%-7s %s\n' "${sh}:" "$("$sh" -c "$code")"
    done

Which produces:

    bash: <123> <456>
    zsh: <1230456>
    ksh: <123> <456> # AT&T ksh
    mksh: <1230456>
    posh: <1230456>
    dash: <123> <456>
    bb: <123> <456> # Busybox ash
Desired ActionImprove the wording so that either:

a) Field splitting is either explicitly required or explicitly disallowed on arithmetic expansion.

b) Field splitting is explicitly unspecified for arithmetic expansion.
Tagstc2-2008

Activities

Don Cragun

2014-04-10 15:40

manager   bugnote:0002220

Last edited: 2014-04-10 15:50

Interpretation response
------------------------
The standard is unclear on this issue, and no conformance distinction can be made between alternative implementations based on this. This is being referred to the sponsor.

Rationale:
-------------
Section 2.6.5 doesn't mention arithmetic expansion (which specifies when field splitting is done), but section 2.6 (where is talks about the order of word expansions) does require field splitting after arithmetic expansions.

Notes to the Editor (not part of this interpretation):
-------------------------------------------------------
Change:
  The shell shall treat each character of the IFS as a delimiter and use the delimiters as field
  terminators to split the results of parameter expansion and command substitution into fields.
on P2333, L74136-74137 to:
  The shell shall treat each character of the IFS as a delimiter and use the delimiters as field
  terminators to split the results of parameter expansion, command substitution, and arithmetic
  expansion into fields.

ajosey

2014-05-02 09:27

manager   bugnote:0002243

Interpretation proposed 2 May 2014

ajosey

2014-06-25 10:13

manager   bugnote:0002278

Interpretation approved 25 June 2014

Issue History

Date Modified Username Field Change
2014-04-06 08:15 ormaaj New Issue
2014-04-06 08:15 ormaaj Status New => Under Review
2014-04-06 08:15 ormaaj Assigned To => ajosey
2014-04-06 08:15 ormaaj Name => Dan Douglas
2014-04-06 08:15 ormaaj Section => 2.6.5
2014-04-06 08:15 ormaaj Page Number => 2333
2014-04-06 08:15 ormaaj Line Number => 74133
2014-04-07 15:15 geoffclare Project 2008-TC1 => 1003.1(2013)/Issue7+TC1
2014-04-10 15:40 Don Cragun Interp Status => Pending
2014-04-10 15:40 Don Cragun Note Added: 0002220
2014-04-10 15:40 Don Cragun Status Under Review => Interpretation Required
2014-04-10 15:40 Don Cragun Resolution Open => Accepted As Marked
2014-04-10 15:41 Don Cragun Final Accepted Text => See 0000832:0002220.
2014-04-10 15:44 Don Cragun Tag Attached: tc2-2008
2014-04-10 15:50 Don Cragun Note Edited: 0002220
2014-05-02 09:27 ajosey Interp Status Pending => Proposed
2014-05-02 09:27 ajosey Note Added: 0002243
2014-06-25 10:13 ajosey Interp Status Proposed => Approved
2014-06-25 10:13 ajosey Note Added: 0002278
2019-06-10 08:54 agadmin Status Interpretation Required => Closed