View Issue Details
| ID | Project | Category | View Status | Date Submitted | Last Update |
|---|---|---|---|---|---|
| 0001978 | 1003.1(2024)/Issue8 | Shell and Utilities | public | 2026-04-01 00:29 | 2026-05-15 00:44 |
| Reporter | Love4Boobies | Assigned To | msbrown | ||
| Priority | normal | Severity | Editorial | Type | Enhancement Request |
| Status | Closed | Resolution | Rejected | ||
| Name | Bogdan Barbu | ||||
| Organization | |||||
| User Reference | |||||
| Section | sh | ||||
| Page Number | https://pubs.opengroup.org/onlinepubs/9799919799/utilities/sh.html | ||||
| Line Number | N/A | ||||
| Interp Status | |||||
| Final Accepted Text | |||||
| Summary | 0001978: Standardize .shrc as the default interactive sh start-up file when ENV is unset | ||||
| Description | Many shells support rc files as a way for the user to provide an initialization script for their interactive shell (for example, Bash's .bashrc and the Korn family's .kshrc). However, there is no standard location that the user can rely on for a portable POSIX sh initialization script across compliant systems. The only standard user initialization mechanism in POSIX sh is the ENV environment variable, but that mechanism is only useful if ENV has first been set, typically by a login profile or by implementation-specific start-up processing, and in existing practice it is also used either directly as the interactive initialization file or to name a shell-specific rc file. The following is a proposal to introduce the .shrc file to be used by interactive sh when the ENV variable is not set. This preserves the precedence of the existing standard mechanism, which already commonly takes precedence over per-shell rc-file initialization, and provides a standard fallback location for portable POSIX sh use. This mechanism is essentially the analogue in POSIX sh of the POSIX ex/vi .exrc file (where EXINIT takes precedence over .exrc), and some of the wording has been borrowed from its definition. | ||||
| Desired Action | Append to the definition of ENV in ENVIRONMENT VARIABLES: See the EXTENDED DESCRIPTION section for more details of the initialization phase. Change the definition of HISTFILE in ENVIRONMENT VARIABLES from: ... as the result of commands issued by the user, the file named by the ENV variable, or implementation-defined system start-up files. to: ... as the result of commands issued by the user, the file named by the ENV variable, the .shrc file, or implementation-defined system start-up files. --- Change the definition of HOME in ENVIRONMENT VARIABLES from: Determine the pathname of the user's home directory. The contents of HOME are used in tilde expansion as described in 2.6.1 Tilde Expansion. to: Determine the pathname of the user's home directory. The contents of HOME are used in tilde expansion as described in 2.6.1 Tilde Expansion, [UP]and to determine a pathname of a directory that shall be searched for a shell start-up file named .shrc; see the EXTENDED DESCRIPTION section.[/UP] --- Add new subsection "Initialization in sh" after the opening paragraph in EXTENDED DESCRIPTION: During initialization (before any user commands from the terminal are processed), if the shell is interactive, the following shall occur: 1. If the environment variable ENV is set, the shell shall process it as described in the ENVIRONMENT VARIABLES section. 2. If the ENV variable is not set, and all of the following are true: a. The real and effective user IDs of the process are the same, and the real and effective group IDs of the process are the same. b. The HOME environment variable is not null and not empty. c. The file .shrc in the directory referred to by the HOME environment variable exists. the shell shall execute the shell commands contained in that file. The .shrc file need not be executable. The .shrc file need not be processed if the file can be written by any user other than the user identified by the real (and effective) user ID of the shell process. --- Change in RATIONALE from: In some historical shells, the history file is initialized just after the ENV file has been processed. to: In some historical shells, the history file is initialized just after the ENV file or an implementation-specific interactive shell start-up file has been processed. | ||||
| Tags | No tags attached. | ||||
|
|
I sympathize with the motivation, but I have some concerns. FWIW, I lean on de facto adoption of ~/.profile by running "exec sh -l" to replace my session with one that loads ~/.profile without needing to write ENV. I learned from a recent call that even ~/.profile isn't actually standardized, which adds important context here. A PATH search for "sh" does not imply program control will enter a fresh POSIX compliant environment in the first place. One example being systems (e.g. GUIX?) that link /bin/sh to bash, with operators' assuming POSIXLY_CORRECT is unset. In this scenario the ~/.shrc name is actually misleading, because the "sh" part of the name does not imply a PATH search shall find and invoke a compatible shell. This could be mitigated with names like ~/.posixrc or ~/.xcurc, but that doesn't address my other concern. The other concern being that I have to know the contents of someone's rcfile before diagnosing an issue with shell startup, so now I have to care about file distribution before noticing misuse of POSIX. ENV is different because I don't have to know the contents of the referenced file to know that file is likely to blame for initialization problems. Worse, if your shell allows spoofing "unset" (like ash does), and your proposal allows loading ~/.shrc without needing "set -l" (which is the impression I get from your description), then every shell in the field that alleges POSIX compliance ends up with two opportunities to defect. Having ENV as the only standard initialization mechanism simplifies diagnostics, and makes the transition from normative to subjective semantics clear. Why complicate that? EDITS: Rephrasing to focus on diagnostics, remove fluff. Also tried HTML formatting here. Didn't work. |
|
|
The group reviewed the proposal regarding standardizing a start-up file during the teleconference on 2026-05-14. After discussion, it was agreed that the request does not have enough evidence of common behavior between the multiple shells and their uses today (as described in part in 0001978:0007428 ). The issue is therefore rejected. |
| Date Modified | Username | Field | Change |
|---|---|---|---|
| 2026-04-01 00:29 | Love4Boobies | New Issue | |
| 2026-05-14 16:52 | sgerard | Note Added: 0007428 | |
| 2026-05-14 16:55 | sgerard | Note Edited: 0007428 | |
| 2026-05-14 16:55 | sgerard | Note Edited: 0007428 | |
| 2026-05-14 17:10 | sgerard | Note Edited: 0007428 | |
| 2026-05-14 17:15 | sgerard | Note Edited: 0007428 | |
| 2026-05-14 17:24 | sgerard | Note Edited: 0007428 | |
| 2026-05-15 00:44 | msbrown | Assigned To | => msbrown |
| 2026-05-15 00:44 | msbrown | Status | New => Closed |
| 2026-05-15 00:44 | msbrown | Resolution | Open => Rejected |
| 2026-05-15 00:44 | msbrown | Note Added: 0007429 |