0

Does dash have a non-interactive non-login rc file? I've read the man page, which recommends .profile for login shells and $ENV environment variable for interactive shells.

Is there anything that runs for non-interactive non-login shells, such as zsh's zshenv files, or bash's $BASH_ENV environment variable? Is there an equivalent file for Bourne shell too?


Best I can come up with so far (although not ideal at all as it requires me editing every single script) is to edit the shebang as follows:

#!/bin/sh /path/to/script

f

where /path/to/script contains

f() { echo "/path/to/script"; }
  • Why the downvote? – Nick Bull Feb 6 at 8:56
1

A typical shell does not have an rc file that is read for non-interactive shells.

.profileis read for a login shell that is identified by an argv[0] that starts with a -.

$ENV is read by an interactive POSIX shell and if not set already, the shell uses it's own default. This is .kshrc for ksh, .bashrc for bash and .shrc for newer versions of the Bourne Shell.

Dash however does not define a default $ENV and thus typically does not read it, even when in interactive mode.

| improve this answer | |
  • What a shame! :( – Nick Bull Feb 5 at 13:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.