View Issue Details
ID | Project | Category | View Status | Date Submitted | Last Update |
---|---|---|---|---|---|
0000764 | 1003.1(2008)/Issue 7 | Shell and Utilities | public | 2013-10-10 13:39 | 2013-10-31 16:30 |
Reporter | fbauzac | Assigned To | ajosey | ||
Priority | normal | Severity | Editorial | Type | Clarification Requested |
Status | Closed | Resolution | Rejected | ||
Name | Fabrice Bauzac | ||||
Organization | |||||
User Reference | |||||
Section | Shell command language 2.5.2 - Parameters and Variables | ||||
Page Number | 2302 | ||||
Line Number | 72538-72539 | ||||
Interp Status | --- | ||||
Final Accepted Text | |||||
Summary | 0000764: Clarify the value of $0 with regards to the dot (.) command | ||||
Description | Hello, In the page http://pubs.opengroup.org/onlinepubs/007908799/xcu/chap2.html in section "Parameters and Variables" $0 is described as: "(Zero.) Expands to the name of the shell or shell script. See sh for a detailed description of how this name is derived." Does this mean that the value of $0 changes for the time of the execution of the dot (.) command? e.g. $ cat main . sourced $ cat sourced echo "$0" What should the command sh main print? "main"? "sourced"? According to the "sh" page http://pubs.opengroup.org/onlinepubs/007908799/xcu/sh.html "Special parameter 0 (see Special Parameters ) is set to the value of command_file. If sh is called using a synopsis form that omits command_file, special parameter 0 is set to the value of the first argument passed to sh from its parent (for example, argv[0] for a C program), which is normally a pathname used to execute the sh utility." So, I guess it means that the dot command does not modify $0. But I think it could be clarified in the description of $0 as such: "(Zero.) Expands to the name of the shell or shell script. See sh for a detailed description of how this name is derived. Note: files executed via the dot (.) command do not count as shell scripts." (Sorry for my bad English. I'm not sure how to reword it better.) Thanks! Best regards Fabrice | ||||
Desired Action | Replace "(Zero.) Expands to the name of the shell or shell script. See sh for a detailed description of how this name is derived." to "(Zero.) Expands to the name of the shell or shell script. Files executed via the dot (.) command do not count as shell scripts. See sh for a detailed description of how this name is derived." | ||||
Tags | No tags attached. |
|
The description of the dot special built-in utility clearly states:The shell shall execute commands from the file in the current environment. and the description of the Shell Execution Environment says that one of the items in the environment is: Shell parameters that are set by variable assignment (see the set special built-in) or from the System Interfaces volume of POSIX.1-2008 environment inherited by the shell when it begins (see the export special built-in) and the positional parameters are included in this item in the list. So, $0 is not allowed to be changed to the name of the operand given to the dot command. |
|
Of course, once 0000252 is incorporated, an implementation could add an extension such as '. -a name file args', similar to the common 'exec -a name' extension used to set argv[0] of an executed app. |
Date Modified | Username | Field | Change |
---|---|---|---|
2013-10-10 13:39 | fbauzac | New Issue | |
2013-10-10 13:39 | fbauzac | Status | New => Under Review |
2013-10-10 13:39 | fbauzac | Assigned To | => ajosey |
2013-10-10 13:39 | fbauzac | Name | => Fabrice Bauzac |
2013-10-10 13:39 | fbauzac | Section | => Shell command language - Parameters and Variables |
2013-10-10 13:39 | fbauzac | Page Number | => na |
2013-10-10 13:39 | fbauzac | Line Number | => na |
2013-10-10 18:57 | Don Cragun | Note Added: 0001876 | |
2013-10-10 19:51 | eblake | Note Added: 0001877 | |
2013-10-10 19:51 | eblake | Relationship added | related to 0000252 |
2013-10-10 20:38 | Don Cragun | Section | Shell command language - Parameters and Variables => Shell command language 2.5.2 - Parameters and Variables |
2013-10-10 20:38 | Don Cragun | Page Number | na => 2302 |
2013-10-10 20:38 | Don Cragun | Line Number | na => 72538-72539 |
2013-10-10 20:38 | Don Cragun | Interp Status | => --- |
2013-10-31 16:30 | Don Cragun | Status | Under Review => Closed |
2013-10-31 16:30 | Don Cragun | Resolution | Open => Rejected |