View Issue Details
| ID | Project | Category | View Status | Date Submitted | Last Update |
|---|---|---|---|---|---|
| 0002002 | 1003.1(2024)/Issue8 | System Interfaces | public | 2026-10-28 18:50 | 2026-10-28 18:50 |
| Reporter | stephane | Assigned To | |||
| Priority | normal | Severity | Objection | Type | Enhancement Request |
| Status | New | Resolution | Open | ||
| Name | Stephane Chazelas | ||||
| Organization | |||||
| User Reference | |||||
| Section | https://pubs.opengroup.org/onlinepubs/9799919799/functions/execl.html | ||||
| Page Number | https://pubs.opengroup.org/onlinepubs/9799919799/functions/execl.html | ||||
| Line Number | https://pubs.opengroup.org/onlinepubs/9799919799/functions/execl.html | ||||
| Interp Status | |||||
| Final Accepted Text | |||||
| Summary | 0002002: execlp() / execvp() and commands starting with - or + | ||||
| Description | Similar to 0001440, related to 0001600 https://pubs.opengroup.org/onlinepubs/9799919799.2024edition/functions/execl.html has: """ In the cases where the other members of the exec family of functions would fail and set errno to [ENOEXEC], the execlp() and execvp() functions shall execute a command interpreter and the environment of the executed command shall be as if the process invoked the sh utility using execl() as follows: execl(<shell path>, <name>, file, <args>, (char *)0); where <shell path> is an unspecified pathname for the sh utility, <name> is an unspecified string, file is the process image file, and where <args> is zero or more parameters corresponding to any initial non-null arguments passed after arg0 for execlp() or to any initial non-null members of argv starting at argv[1] for execvp(). """ "file is the process image file" should probably be "file is the pathname to the process image file", but also, if that pathname starts with - or +, such as when invoked as execlp("-dir-/cmd",...) or execlp("+x",...) and +x was found in the current directory because $PATH contains an empty component, then that path will be taken as an option by sh instead of the path to the file being executed. There's a similar problem in the resolution of 0001600 where #! /path/to/sh
${0##*/} "$@"Should be: #! /path/to/sh --
"${0##*/}" "$@"(leaving that ${0##*/} unquoted to request split+glob also doesn't make sense here) | ||||
| Desired Action | For execlp/execvp, change to: """ execl(<shell path>, <name>, "--", file, <args>, (char *)0); where <shell path> is an unspecified pathname for the sh utility, <name> is an unspecified string, file is the pathname of the process image file, and where <args> is zero or more parameters corresponding to any initial non-null arguments passed after arg0 for execlp() or to any initial non-null members of argv starting at argv[1] for execvp(). """ Apparently Solaris/Illumos prefix the path with ./ if it starts with - (not +) instead (https://github.com/illumos/illumos-gate/blob/7bbcc14f12e8a235cc9668f76da6d2c9ecf14cd4/usr/src/lib/libc/port/gen/execvp.c#L156-L158). We may want to also allow that even if that means that changes the value of `$0` in the shell script. For the builtins (0001600 resolution): #! /path/to/sh --
"${0##*/}" "$@"Using a single dash as in: #! /path/to/sh -
"${0##*/}" "$@"May be more canonical as that's what was done for the Bourne shell. | ||||
| Tags | No tags attached. | ||||
| Date Modified | Username | Field | Change |
|---|---|---|---|
| 2026-10-28 18:50 | stephane | New Issue |