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
0000942 [1003.1(2013)/Issue7+TC1] Shell and Utilities Editorial Error 2015-04-28 21:49 2020-10-02 10:47
Reporter stephane View Status public  
Assigned To
Priority normal Resolution Accepted As Marked  
Status Closed  
Name Stephane Chazelas
Organization
User Reference
Section expr
Page Number 2740-2741
Line Number 89697,89702,89724,89737
Interp Status ---
Final Accepted Text Note: 0002709
Summary 0000942: Several problems in "expr" examples
Description 1.

> The following works reliably:
>
> expr X$a = X=

That won't work reliably if $a contains characters present in $IFS or wildcard characters.

Also X$a == X= doesn't necessarily imply $a == = if there are collation elements that start with X in the locale.

2.

> a=$(expr $a + 1)

Missing quotes again

3.

> expr "$VAR" : '.*'

Fails for values of $VAR that are expr operators.
Desired Action 1. Quote the variable in both examples:

   expr "$a" = =
   exec "X$a" = X=

2. a=$(expr "$a" + 1)

3. expr '(' "X$VAR" : '.*' ')' - 1
Tags tc2-2008
Attached Files

- Relationships
related to 0001407Applied Online Pubs HTML edition has expr table in reversed order 

-  Notes
(0002640)
eblake (manager)
2015-04-28 21:59

For example 2, if it is known that $a is numeric (which is assumed to be the case, since we are assigning the incremented value back to a), then there are no IFS characters or wildcards that need protection (modulo a very-unlikely setting of IFS that includes digits).

Still, I agree that teaching people to be consistent with quoting is easier than explaining which situations do not require quoting.
(0002709)
geoffclare (manager)
2015-06-11 16:13

At line 89637 (p 2739, Extended Description), change "increasing precedence" to "decreasing precedence", then rearrange the lines into the following order (still with each group of lines forming a row of the table):
    line 89640 (table header)
    line 89668-89760 (integer, string)
    line 89665-89667 (parentheses)
    line 89664 (:)
    line 98659-89663 (*, /, %)
    line 89657-89658 (+, -)
    line 89646-89656 (=, >, >=, <, <=, !=)
    line 89644-89645 (&)
    line 89641-89643 (|)

Move lines 89710-89722 to start of Application Usage (before line 89695).

Change line 89697 (page 2740) to:
    expr "$a" = ’=’

Change line 89702 (page 2740) to:
    expr "X$a" = X=

Change line 89724 (page 2741) to:
    a=$(expr "$a" + 1)

Change line 89737 to:
    expr "X$VAR" : '.*'  - 1

- Issue History
Date Modified Username Field Change
2015-04-28 21:49 stephane New Issue
2015-04-28 21:49 stephane Name => Stephane Chazelas
2015-04-28 21:49 stephane Section => http://pubs.opengroup.org/onlinepubs/9699919799/utilities/expr.html#tag_20_42_16 [^]
2015-04-28 21:49 stephane Page Number => http://pubs.opengroup.org/onlinepubs/9699919799/utilities/expr.html#tag_20_42_16 [^]
2015-04-28 21:49 stephane Line Number => http://pubs.opengroup.org/onlinepubs/9699919799/utilities/expr.html#tag_20_42_16 [^]
2015-04-28 21:59 eblake Note Added: 0002640
2015-06-11 16:13 geoffclare Note Added: 0002709
2015-06-11 16:15 geoffclare Section http://pubs.opengroup.org/onlinepubs/9699919799/utilities/expr.html#tag_20_42_16 [^] => expr
2015-06-11 16:15 geoffclare Page Number http://pubs.opengroup.org/onlinepubs/9699919799/utilities/expr.html#tag_20_42_16 [^] => 2740-2741
2015-06-11 16:15 geoffclare Line Number http://pubs.opengroup.org/onlinepubs/9699919799/utilities/expr.html#tag_20_42_16 [^] => 89697,89702,89724,89737
2015-06-11 16:15 geoffclare Interp Status => ---
2015-06-11 16:15 geoffclare Final Accepted Text => Note: 0002709
2015-06-11 16:15 geoffclare Status New => Resolved
2015-06-11 16:15 geoffclare Resolution Open => Accepted As Marked
2015-06-11 16:15 geoffclare Tag Attached: tc2-2008
2019-06-10 08:54 agadmin Status Resolved => Closed
2020-10-02 10:47 geoffclare Relationship added related to 0001407


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