Anonymous | Login | 2023-12-06 14:20 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 | ||
0001272 | [1003.1(2016/18)/Issue7+TC2] Shell and Utilities | Objection | Error | 2019-07-24 20:34 | 2019-11-20 16:15 | ||
Reporter | stephane | View Status | public | ||||
Assigned To | |||||||
Priority | normal | Resolution | Accepted As Marked | ||||
Status | Applied | ||||||
Name | Stephane Chazelas | ||||||
Organization | |||||||
User Reference | |||||||
Section | colon special utility | ||||||
Page Number | 2388 (in 2018 edition) | ||||||
Line Number | |||||||
Interp Status | --- | ||||||
Final Accepted Text | Note: 0004523 | ||||||
Summary | 0001272: colon doesn't "expand its arguments" and must not process options | ||||||
Description |
The colon special utility specification says: > This utility shall only expand command arguments. That is not true. ":" doesn't do anything with its arguments. I beleive what that text meant was that ":" is a special builtin as any other and not a comment introducing token in the shell syntax contrary to "#", so that what follows is subject to all expansions. For instance that in: : "$((a = 1))" /*/*/*/* Those arithmetic and pathname expansions and their side effects are still performed before the ":" utility is invoked. But what the ":" utility gets as arguments is the result of those expansions, and it doesn't do anything with them. Also, it says "OPTIONS: None". But that would still mean that implementations are free to support some as extensions. Worse, since ":" is a special builtin, that means that implementations are not required to support "--" as an end-of-option marker. Yet, as demonstrated in the (broken, see below) first example, things like: : "${X=abc}" are a common idiom. In the current version of the spec however, that produces unspecified results unless $X can be guaranteed not to start with a "-" (and : -- "${X=abc}" doesn't fix it). I don't know of any shell implementation whose ":" handles options. Even ksh93 where most builtins support common --help/--man/--author options doesn't do it for ":". POSIX should make it clear that no option processing should be done, that all the arguments are to be ignored. The first example: > : ${X=abc} > if false > then : > else echo $X > fi has a few poor shell coding practice instances/bugs: - missing quotes around expansions - usage of echo for arbitrary data |
||||||
Desired Action |
Change the DESCRIPTION to: This utility shall do nothing and return with a 0 exit status. Change OPTIONS to: The null utility shall not process any option. All arguments shall be ignored whether they start with "-" or not. If deemed necessary, add an "APPLICATION USAGE" section clarifying that ":" differs from "#" in that it's a command and not a token in the shell syntax. And that it differs from "true" in that it's a special utility, accepts arguments that it ignores and doesn't process options (that's also the case of most true implementations but not all). Change the first example to: : "${X=abc}" if false then : else printf '%s\n' "$X" fi On an unrelated note, as it's very unintuitive, it may be worth also adding to the second example description as a reminder: "colon being a special utility, if the z file cannot be opened, it shall cause the shell to exit". |
||||||
Tags | tc3-2008 | ||||||
Attached Files | |||||||
|
![]() |
|||
Date Modified | Username | Field | Change |
2019-07-24 20:34 | stephane | New Issue | |
2019-07-24 20:34 | stephane | Name | => Stephane Chazelas |
2019-07-24 20:34 | stephane | Section | => colon special utility |
2019-07-24 20:34 | stephane | Page Number | => 2388 (in 2018 edition) |
2019-08-15 16:15 | geoffclare | Note Added: 0004523 | |
2019-08-15 16:16 | geoffclare | Interp Status | => --- |
2019-08-15 16:16 | geoffclare | Final Accepted Text | => Note: 0004523 |
2019-08-15 16:16 | geoffclare | Status | New => Resolved |
2019-08-15 16:16 | geoffclare | Resolution | Open => Accepted As Marked |
2019-08-15 16:16 | geoffclare | Tag Attached: tc3-2008 | |
2019-11-20 16:15 | geoffclare | Status | Resolved => Applied |
Mantis 1.1.6[^] Copyright © 2000 - 2008 Mantis Group |