Anonymous | Login | 2024-10-09 03:51 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 | ||
0001157 | [1003.1(2016/18)/Issue7+TC2] Shell and Utilities | Objection | Clarification Requested | 2017-07-26 15:40 | 2024-06-11 09:09 | ||
Reporter | geoffclare | View Status | public | ||||
Assigned To | |||||||
Priority | normal | Resolution | Accepted | ||||
Status | Closed | ||||||
Name | Geoff Clare | ||||||
Organization | The Open Group | ||||||
User Reference | |||||||
Section | 2.14 exec | ||||||
Page Number | 2397-2398 | ||||||
Line Number | 76683-76745 | ||||||
Interp Status | --- | ||||||
Final Accepted Text | See Note: 0004204 | ||||||
Summary | 0001157: major overhaul of exec special built-in | ||||||
Description |
Discussion on the mailing list identified some problems with the description of the exec special built-in utility; it is in need of a major overhaul. The discussion was triggered by a question about whether exec can execute functions. Although it is known that the original intent was that exec can only execute non-built-in utilities (because the POSIX description was based on ksh88), and it is clear from the EXIT STATUS section that the standard requires this (because it refers to a program which overlays the shell process), and all of the widely used shells conform to this, there are some lesser used shells (notably mksh and zsh) which allow execution of functions and built-in utilities via exec, and there appear to be pros and cons for both approaches. Therefore, the proposed changes have two options: one which clarifies the current requirement and one which allows both behaviours. |
||||||
Desired Action |
On page 2367 line 75579-75599 section 2.9.1 replace item b with:Otherwise, the shell shall execute a non-built-in utility as described in [xref to 2.9.1.2]. On page 2367 line 75608-75621 section 2.9.1 replace item 2 with: If the command name contains at least one <slash>, the shell shall execute a non-built-in utility as described in [xref to 2.9.1.2]. On page 2368 line 75627 section 2.9.1 add a new section: 2.9.1.2 Non-built-in Utility Execution On page 2397 line 76683 section 2.14 exec, change NAME from: exec - execute commands and open, close, or copy file descriptorsto: exec - perform redirections in the current shell or execute a utility On page 2397 line 76685 section 2.14 exec, change SYNOPSIS from: exec [command [argument...]]to: exec [utility [argument...]] On page 2397 line 76687-76689 section 2.14 exec, change: The exec utility shall open, close, and/or copy file descriptors as specified by any redirections as part of the command.to: If exec is specified with no operands, any redirections associated with the exec command shall be made in the current shell execution environment. If any file descriptors with numbers greater than 2 are opened by those redirections, ... On page 2397 line 76693 section 2.14 exec, append to the paragraph: If the result of the redirections would be that file descriptor 0, 1, or 2 is closed, implementations may open the file descriptor to an unspecified file. On page 2397 line 76694-76696 section 2.14 exec, change: If exec is specified with command, it shall replace the shell with command without creating a new process. If arguments are specified, they shall be arguments to command. Redirection affects the current shell execution environment. to one of the following options: OPTION 1 If exec is specified with a utility operand, the shell shall execute a non-built-in utility as described in [xref to 2.9.1.2] with utility as the command name and the argument operands (if any) as the command arguments. OPTION 2 If exec is specified with a utility operand: On page 2397 line 76718-76722 section 2.14 exec, change EXIT STATUS from: If command is specified, exec shall not return to the shell; rather, the exit status of the process shall be the exit status of the program implementing command, which overlaid the shell. If command is not found, the exit status shall be 127. If command is found, but it is not an executable utility, the exit status shall be 126. If a redirection error occurs (see [xref to 2.8.1]), the shell shall exit with a value in the range 1-125. Otherwise, exec shall return a zero exit status.to: If utility is specified and is executed, exec shall not return to the shell; rather, the exit status of the current shell execution environment shall be the exit status of utility. If utility is specified and an attempt to execute it as a non-built-in utility fails, the exit status shall be as described in [xref to 2.9.1.2]. If a redirection error occurs (see [xref to 2.8.1]), the exit status shall be a value in the range 1-125. Otherwise, exec shall return a zero exit status. If OPTION 1 is chosen above, then also make the following two changes. On page 2398 line 76737 section 2.14 exec, add to EXAMPLES: An application that is not concerned with strict conformance can make use of optional %g support known to be present in the implementation's printf utility by ensuring that any shell built-in version is not executed instead, and using a subshell so that the shell continues afterwards: On page 2694 line 87961 section env, change: Therefore, shell functions, special built-ins, and built-ins that are only provided by the shell are not found.to: Therefore, shell functions, special built-ins, and built-ins that are only provided by the shell are not found by this type of env implementation. However, env can be implemented as a shell built-in, in which case it may be able to execute shell functions and built-ins. An application wishing to ensure execution of a non-built-in utility can use exec in a subshell for this purpose. If OPTION 2 is chosen above, then also make the following three changes. On page 2398 line 76726 section 2.14 exec, change APPLICATION USAGE from: None.to: Since it is unspecified whether exec executes built-in utilities and functions, portable applications cannot rely on the use of exec in a subshell to bypass these and ensure the execution of a non-built-in utility. The only portable ways to ensure execution of a non-built-in utility are: On page 2398 line 76745 section 2.14 exec, add env to SEE ALSO. On page 2694 line 87961 section env, change: Therefore, shell functions, special built-ins, and built-ins that are only provided by the shell are not found.to: Therefore, shell functions, special built-ins, and built-ins that are only provided by the shell are not found by this type of env implementation. However, env can be implemented as a shell built-in, in which case it may be able to execute shell functions and built-ins. For methods of ensuring execution of a non-built-in utility, see the APPLICATION USAGE section of [xref to exec]. |
||||||
Tags | tc3-2008 | ||||||
Attached Files | |||||||
|
Relationships | |||||||
|
Issue History | |||
Date Modified | Username | Field | Change |
2017-07-26 15:40 | geoffclare | New Issue | |
2017-07-26 15:40 | geoffclare | Name | => Geoff Clare |
2017-07-26 15:40 | geoffclare | Organization | => The Open Group |
2017-07-26 15:40 | geoffclare | Section | => 2.14 exec |
2017-07-26 15:40 | geoffclare | Page Number | => 2397-2398 |
2017-07-26 15:40 | geoffclare | Line Number | => 76683-76745 |
2017-07-26 15:40 | geoffclare | Interp Status | => --- |
2017-07-26 15:49 | geoffclare | Desired Action Updated | |
2017-09-04 16:15 | kre | Note Added: 0003822 | |
2017-09-04 17:28 | kre | Note Edited: 0003822 | |
2019-01-10 17:26 | eblake | Relationship added | related to 0000252 |
2019-01-10 17:32 | nick | Note Added: 0004204 | |
2019-01-10 17:33 | nick | Final Accepted Text | => See Note: 0004204 |
2019-01-10 17:33 | nick | Resolution | Open => Accepted |
2019-01-10 17:33 | nick | Tag Attached: issue8 | |
2019-01-10 17:34 | nick | Tag Detached: issue8 | |
2019-01-10 17:34 | nick | Tag Attached: tc3-2008 | |
2019-01-10 17:34 | nick | Status | New => Resolved |
2019-01-10 17:59 | shware_systems | Note Added: 0004205 | |
2019-01-10 18:00 | shware_systems | Note Edited: 0004205 | |
2019-11-07 09:38 | geoffclare | Status | Resolved => Applied |
2024-06-11 09:09 | agadmin | Status | Applied => Closed |
Mantis 1.1.6[^] Copyright © 2000 - 2008 Mantis Group |