View Issue Details

IDProjectCategoryView StatusLast Update
00009891003.1(2008)/Issue 7Shell and Utilitiespublic2016-07-14 15:57
Reporterjoerg Assigned Toajosey  
PrioritynormalSeverityEditorialTypeError
Status ClosedResolutionDuplicate 
NameJörg Schilling
Organization
User Reference
Section2.6.2
Page Number2328-2329
Line Number73954,73980,73981
Interp Status---
Final Accepted Text
Summary0000989: Contradicting claims for shell parameter substitution
DescriptionOn line 73954, the text says for "Assign default values":

     In all cases, the final value of parameter shall be substituted.

On lines 73980/81, the text says:

     In all cases shown with ‘‘substitute’’, the expression is replaced with
     the value shown. In all cases shown with ‘‘assign’’, parameter is assigned
     that value, which also replaces the expression.

BTW; I understand "which" as related to "that value".

This is a case that matches this test case:

unset unsetvar; printf '%s\n' ${unsetvar="foo bar"}

where the Bourne Shell prints:
foo bar
and ksh prints:
foo
bar

It seems that the Bourne Shell is aligned with the second text (and substitutes "word") while ksh is aligned with the first text (and substitutes $parameter after the assignement).
Desired ActionEither allow both variants or correct one of both descriptions after deciding on which version should be correct.
TagsNo tags attached.

Relationships

duplicate of 0000221 Closedajosey poor wording about even quotes in double quoted parameter expansion 

Activities

geoffclare

2015-10-09 15:11

manager   bugnote:0002870

I don't see any conflict here. It is clear from "parameter is assigned that value, which also replaces the expression" that the value assigned to parameter is the value that replaces the expression. The detail of what value is assigned to parameter is covered in the earlier text (and is modified by TC2). The table and the paragraph after it are just there to summarize the effect of a colon; they don't need to give any details of how the assignment is done, just a statement about which cases cause an assignment to be performed.

shware_systems

2015-10-11 18:19

reporter   bugnote:0002871

Last edited: 2015-10-12 10:29

After looking at this again (I was thinking of both printf arguments as quoted, but they aren't), the effect should be the same as if:
unset unsetvar; unsetvar = "foo bar" printf '%s\n' ${unsetvar}

were used. While both are storing "foo bar", not simply "foo", because the ${..} expression isn't double quoted also, it is ksh that is properly storing <foo bar>, after quote removal on =word, and then doing field splitting after the substitution. Bourne Shell is behaving as if <"foo bar"> is getting stored, and the stored quotes override the field splitting, which is more a bug with the TC2 changes, imo.

geoffclare

2015-10-12 08:30

manager   bugnote:0002872

The description compares ksh with the original Bourne Shell, not with bash. Bash currently behaves the same as ksh (it changed somewhere between bash 4.1.5 and 4.2.37).

shware_systems

2015-10-12 10:31

reporter   bugnote:0002873

yes, ty for spotting it. Note edited.

joerg

2015-10-12 14:34

reporter   bugnote:0002874

Last edited: 2015-10-12 14:38

The Bourne Shell follows the second description, as it assigns "value" and replaces the expresssion by the "value".

Given that the "value" is a quoted string, there is no word splitting and thus printf prints only one line.

Ksh however followes the first text and assigns the "value" and then expands the variable "parameter".

Given that ${parameter} is not quoted, work splitting applies and printf prints two lines.

BTW: the second text was taken from the Bourne Shell man page and the first text was taken from the ksh man page that is in conflict with the Bourne Shell man page.

chet_ramey

2015-10-12 18:31

reporter   bugnote:0002875

This was covered and discussed as part of http://austingroupbugs.net/view.php?id=221. There is an example in there that directly addresses this case. Bash changed as a result of that interpretation.

Issue History

Date Modified Username Field Change
2015-10-09 13:39 joerg New Issue
2015-10-09 13:39 joerg Status New => Under Review
2015-10-09 13:39 joerg Assigned To => ajosey
2015-10-09 13:39 joerg Name => Jörg Schilling
2015-10-09 13:39 joerg Section => 2.6.2
2015-10-09 13:39 joerg Page Number => 2328-2329
2015-10-09 13:39 joerg Line Number => 73954,73980,73981
2015-10-09 15:11 geoffclare Note Added: 0002870
2015-10-11 18:19 shware_systems Note Added: 0002871
2015-10-11 18:20 shware_systems Note Edited: 0002871
2015-10-12 08:30 geoffclare Note Added: 0002872
2015-10-12 10:29 shware_systems Note Edited: 0002871
2015-10-12 10:31 shware_systems Note Added: 0002873
2015-10-12 14:34 joerg Note Added: 0002874
2015-10-12 14:35 joerg Note Edited: 0002874
2015-10-12 14:38 joerg Note Edited: 0002874
2015-10-12 18:31 chet_ramey Note Added: 0002875
2015-10-15 15:38 nick Relationship added related to 0000221
2016-07-14 15:56 Don Cragun Relationship replaced duplicate of 0000221
2016-07-14 15:57 geoffclare Interp Status => ---
2016-07-14 15:57 geoffclare Status Under Review => Closed
2016-07-14 15:57 geoffclare Resolution Open => Duplicate