From 3135b4ce8d5974e1dee530928a8aacffe7eac433 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sat, 3 Dec 2016 00:22:17 +1300 Subject: Split ~/.shrc off stub ~/.shinit file NetBSD sh(1) and possible others don't tolerate a `return` short-circuit for ENV, which means that because that implementation also sources ENV if set regardless of whether the shell is interactive or not, all of the interactive stuff in ~/.shrc and ~/.shrc.d gets uselessly sourced and loaded up for non-interactive invocations of sh(1). To work around this, I've set ENV to be a new ~/.shinit file instead, which sources the ~/.shrc file only if the shell is interactive. ~/.shinit is the filename suggested in the man page for NetBSD sh(1) and Debian dash(1) as well. NetBSD's documented behaviour seems to be contrary to POSIX 2003: > ENV: This variable, when and only when an interactive shell is > invoked, shall be subjected to parameter expansion (see Parameter > Expansion ) by the shell, and the resulting value shall be used as a > pathname of a file containing shell commands to execute in the > current environment. No matter; this works fine, and makes non-interactive invocations of sh(1) on NetBSD much faster. --- sh/profile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'sh/profile') diff --git a/sh/profile b/sh/profile index afc308ea..fd87b8fa 100644 --- a/sh/profile +++ b/sh/profile @@ -7,8 +7,8 @@ for sh in "$HOME"/.profile.d/*.sh ; do done unset -v sh -# If ENV is unset after running those scripts and ~/.shrc exists, set it as ENV -if [ -z "$ENV" ] && [ -f "$HOME"/.shrc ] ; then - ENV=$HOME/.shrc +# If ENV is still unset, and ~/.shinit exists, use that +if [ -z "$ENV" ] && [ -f "$HOME"/.shinit ] ; then + ENV=$HOME/.shinit export ENV fi -- cgit v1.2.3