Anonymous | Login | 2025-01-16 19:17 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 | ||
0000888 | [1003.1(2013)/Issue7+TC1] Shell and Utilities | Objection | Clarification Requested | 2014-11-05 17:00 | 2019-06-10 08:54 | ||
Reporter | geoffclare | View Status | public | ||||
Assigned To | |||||||
Priority | normal | Resolution | Accepted | ||||
Status | Closed | ||||||
Name | Geoff Clare | ||||||
Organization | The Open Group | ||||||
User Reference | |||||||
Section | 2.5.2 Special Parameters | ||||||
Page Number | 2324 | ||||||
Line Number | 73742-73754 | ||||||
Interp Status | Approved | ||||||
Final Accepted Text | See Note: 0002547. | ||||||
Summary | 0000888: Clarify expansion of '@' and '*' special parameters | ||||||
Description |
An email thread started by Stephane Chazelas identified some ways in which the standard is unclear regarding the expansion of the '@' and '*' special parameters. Note that the proposed changes make it optional whether fields resulting from empty positional parameters are discarded when $@ and $* are subject to field splitting. This is to allow the existing variation in behaviour for TC2. A separate enhancement request should be submitted to change "may" to "shall", and remove the relevant "optional" output lines in the examples, in order to tighten this up for Issue 8. |
||||||
Desired Action |
On Page: 2324 Line: 73742-73754 Section: 2.5.2 Special Parameters Replace the descriptions of the '@' and '*' special parameters with: @ 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 [xref to 2.6.5 Field Splitting]. When the expansion occurs within double-quotes, the behavior is unspecified unless one of the following is true: * 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 [xref to 2.6.5 Field Splitting]. When the expansion occurs in a context where field splitting will not be performed, the initial fields shall be joined to form a single field with the value of each parameter separated by the first character of the IFS variable if IFS contains at least one character, or separated by a <space> if IFS is unset, or with no separation if IFS is set to a null string. On Page: 2325 Line: 73791 Section: 2.5.3 Shell Variables In the description of IFS, change from: A string treated as a list of characters that is used for field splitting and to split lines into fields with the read command. If IFS is not set, it shall behave as normal for an unset variable, except that field splitting by the shell and line splitting by the read command shall to: A string treated as a list of characters that is used for field splitting, expansion of the '*' special parameter, and to split lines into fields with the read utility. If the value of IFS includes any bytes that do not form part of a valid character, the results of field splitting, expansion of '*', and use of the read utility are unspecified. If IFS is not set, it shall behave as normal for an unset variable, except that field splitting by the shell and line splitting by the read utility shall On Page: 2328 Line: 73940 Section: 2.6.2 Parameter Expansions Change from: Field splitting shall not be performed on the results of the expansion, with the exception of '@'; see [xref to 2.5.2]. to: Field splitting shall not be performed on the results of the expansion. On Page: 3191 Line: 106806 Section: sh In the ENVIRONMENT VARIABLES section, for IFS change from: A string treated as a list of characters that is used for field splitting and to split lines into fields with the read command. If IFS is not set, it shall behave as normal for an unset variable, except that field splitting by the shell and line splitting by the read command shall to: A string treated as a list of characters that is used for field splitting, expansion of the '*' special parameter, and to split lines into fields with the read utility. If the value of IFS includes any bytes that do not form part of a valid character, the results of field splitting, expansion of '*', and use of the read utility are unspecified. If IFS is not set, it shall behave as normal for an unset variable, except that field splitting by the shell and line splitting by the read utility shall Cross-volume changes to XRAT... On Page: 3680 Line: 125783-125803 Section: C.2.5.2 Special Parameters Change from: Some examples of the '*' and '@' properties, including the concatenation aspects: set "abc" "def ghi" "jkl" echo $* => "abc" "def" "ghi" "jkl" echo "$*" => "abc def ghi jkl" echo $@ => "abc" "def" "ghi" "jkl"but: echo "$@" => "abc" "def ghi" "jkl" echo "xx$@yy" => "xxabc" "def ghi" "jklyy" echo "$@$@" => "abc" "def ghi" "jklabc" "def ghi&quo t; "jkl"In the preceding examples, the double-quote characters that appear after the "=>" do not appear in the output and are used only to illustrate word boundaries. The following example illustrates the effect of setting IFS to a null string: $ IFS='' $ set foo bar bam $ echo "$@" foo bar bam $ echo "$*" foobarbam $ unset IFS $ echo "$*" foo bar bam to: The following examples illustrate some of the ways in which '*' and '@' can be expanded: <tt>set "abc" "def ghi" "jkl" unset novar IFS=' ' # a space printf '%s\n' $* abc def ghi jkl printf '%s\n' "$*" abc def ghi jkl printf '%s\n' xx$*yy xxabc def ghi jklyy printf '%s\n' "xx$*yy" xxabc def ghi jklyy printf '%s\n' $@ abc def ghi jkl printf '%s\n' "$@" abc def ghi jkl printf '%s\n' ${1+"$@"} abc def ghi jkl printf '%s\n' ${novar-"$@"} abc def ghi jkl printf '%s\n' xx$@yy xxabc def ghi jklyy printf '%s\n' "xx$@yy" xxabc def ghi jklyy printf '%s\n' $@$@ abc def ghi jklabc def ghi jkl printf '%s\n' "$@$@" abc def ghi jklabc def ghi jkl IFS=':' printf '%s\n' "$*" abc:def ghi:jkl var=$*; printf '%s\n' "$var" abc:def ghi:jkl var="$*"; printf '%s\n' "$var" abc:def ghi:jkl unset var printf '%s\n' ${var-$*} abc def ghi jkl printf '%s\n' "${var-$*}" abc:def ghi:jkl printf '%s\n' ${var-"$*"} abc:def ghi:jkl printf '%s\n' ${var=$*} abc def ghi jkl printf 'var=%s\n' "$var" var=abc:def ghi:jkl unset var printf '%s\n' "${var=$*}" abc:def ghi:jkl printf 'var=%s\n' "$var" var=abc:def ghi:jkl IFS='' # null printf '%s\n' "$*" abcdef ghijkl var=$*; printf '%s\n' "$var" abcdef ghijkl var="$*"; printf '%s\n' "$var" abcdef ghijkl unset var printf '%s\n' ${var-$*} abcdef ghijkl printf '%s\n' "${var-$*}" abcdef ghijkl printf '%s\n' ${var-"$*"} abcdef ghijkl printf '%s\n' ${var=$*} abcdef ghijkl printf 'var=%s\n' "$var" var=abcdef ghijkl unset var printf '%s\n' "${var=$*}" abcdef ghijkl printf 'var=%s\n' "$var" var=abcdef ghijkl printf '%s\n' "$@" abc def ghi jkl unset IFS printf '%s\n' "$*" abc def ghi jkl var=$*; printf '%s\n' "$var" abc def ghi jkl var="$*"; printf '%s\n' "$var" abc def ghi jkl unset var printf '%s\n' ${var-$*} abc def ghi jkl printf '%s\n' "${var-$*}" abc def ghi jkl printf '%s\n' ${var-"$*"} abc def ghi jkl printf '%s\n' ${var=$*} abc def ghi jkl printf 'var=%s\n' "$var" var=abc def ghi jkl unset var printf '%s\n' "${var=$*}" abc def ghi jkl printf 'var=%s\n' "$var" var=abc def ghi jkl printf '%s\n' "$@" abc def ghi jkl set one "" three printf '[%s]\n' $* [one] []</tt> (this line of output is optional)<tt> [three] printf '[%s]\n' $@ [one] []</tt> (this line of output is optional)<tt> [three] set -- printf '[%s]\n' foo "$*" [foo] [] printf '[%s]\n' foo "$novar$*$(echo)" [foo] [] printf '[%s]\n' foo $@ [foo] printf '[%s]\n' foo "$@" [foo] printf '[%s]\n' foo ''$@ [foo] [] printf '[%s]\n' foo ''"$@" [foo] [] printf '[%s]\n' foo "$novar$@$(echo)" [foo] []</tt> (this line of output is optional)<tt> printf '[%s]\n' foo ''"$novar$@$(echo)" [foo] []</tt> In all of the following commands the results of the expansion of '@' (if performed) are unspecified: <tt>var=$@ var="$@" printf '%s\n' ${var=$@} printf '%s\n' "${var=$@}" printf '%s\n' ${var="$@"} printf '%s\n' ${var?$@} printf '%s\n' "${var?$@}" printf '%s\n' ${var?"$@"} printf '%s\n' ${#@} printf '%s\n' "${#@}" printf '%s\n' ${@%foo} printf '%s\n' "${@%foo}" printf '%s\n' ${@#foo} printf '%s\n' "${@#foo}" printf '%s\n' ${var%$@} printf '%s\n' "${var%$@}" printf '%s\n' ${var%"$@"} printf '%s\n' ${var%%$@} printf '%s\n' "${var%%$@}" printf '%s\n' ${var%%"$@"} printf '%s\n' ${var#$@} printf '%s\n' "${var#$@}" printf '%s\n' ${var#"$@"} printf '%s\n' ${var##$@} printf '%s\n' "${var##$@}" printf '%s\n' ${var##"$@"}</tt> |
||||||
Tags | tc2-2008 | ||||||
Attached Files | |||||||
|
Issue History | |||
Date Modified | Username | Field | Change |
2014-11-05 17:00 | geoffclare | New Issue | |
2014-11-05 17:00 | geoffclare | Name | => Geoff Clare |
2014-11-05 17:00 | geoffclare | Organization | => The Open Group |
2014-11-05 17:00 | geoffclare | Section | => 2.5.2 Special Parameters |
2014-11-05 17:00 | geoffclare | Page Number | => 2324 |
2014-11-05 17:00 | geoffclare | Line Number | => 73742-73754 |
2014-11-05 17:00 | geoffclare | Interp Status | => --- |
2014-11-05 17:11 | geoffclare | Desired Action Updated | |
2014-11-05 17:17 | geoffclare | Desired Action Updated | |
2014-11-05 17:21 | geoffclare | Note Added: 0002430 | |
2015-02-19 16:23 | geoffclare | Desired Action Updated | |
2015-02-19 16:27 | Don Cragun | Interp Status | --- => Pending |
2015-02-19 16:27 | Don Cragun | Note Added: 0002547 | |
2015-02-19 16:28 | Don Cragun | Final Accepted Text | => See Note: 0002547. |
2015-02-19 16:28 | Don Cragun | Status | New => Interpretation Required |
2015-02-19 16:28 | Don Cragun | Resolution | Open => Accepted |
2015-02-19 16:28 | Don Cragun | Tag Attached: tc2-2008 | |
2015-02-19 16:32 | Don Cragun | Note Edited: 0002547 | |
2015-02-20 12:13 | ajosey | Interp Status | Pending => Proposed |
2015-02-20 12:13 | ajosey | Note Added: 0002553 | |
2015-03-23 12:09 | ajosey | Interp Status | Proposed => Approved |
2015-03-23 12:09 | ajosey | Note Added: 0002600 | |
2019-06-10 08:54 | agadmin | Status | Interpretation Required => Closed |
Mantis 1.1.6[^] Copyright © 2000 - 2008 Mantis Group |