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-04-01 00:29 |
| Reporter | Love4Boobies | Assigned To | |||
| Priority | normal | Severity | Editorial | Type | Enhancement Request |
| Status | New | Resolution | Open | ||
| 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. | ||||
| Date Modified | Username | Field | Change |
|---|---|---|---|
| 2026-04-01 00:29 | Love4Boobies | New Issue |