From 4d612862149ca2337f0e78a14eb6a2f43de0ab5c Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Wed, 17 Aug 2016 18:42:56 +1200 Subject: Move interactive tests back into *rc files I don't fully understand why I have to do it this way yet, but if I don't, calling SSH with a command raises "stdin: not a terminal" because ~/.bashrc was called. --- bash/bash_profile | 8 ++++---- bash/bashrc | 6 ++++++ sh/profile | 8 ++++---- sh/shrc | 6 ++++++ 4 files changed, 20 insertions(+), 8 deletions(-) diff --git a/bash/bash_profile b/bash/bash_profile index d0850004..76758083 100644 --- a/bash/bash_profile +++ b/bash/bash_profile @@ -23,7 +23,7 @@ if [[ -d $HOME/.bash_profile.d ]] ; then unset -v bash_profile fi -# If the shell is interactive, and ~/.bashrc exists, source that too -case $- in - *i*) [[ -f "$HOME"/.bashrc ]] && source "$HOME"/.bashrc ;; -esac +# If ~/.bashrc exists, source that too; the test for interactivity is in there +if [[ -f $HOME/.bashrc ]] ; then + source "$HOME"/.bashrc +fi diff --git a/bash/bashrc b/bash/bashrc index 56ab7fda..5b04f979 100644 --- a/bash/bashrc +++ b/bash/bashrc @@ -8,6 +8,12 @@ elif ((BASH_VERSINFO[0] == 2)) && return fi +# Make sure the shell is interactive +case $- in + *i*) ;; + *) return ;; +esac + # Don't do anything if running a restricted shell if shopt -q restricted_shell ; then return diff --git a/sh/profile b/sh/profile index e190d6ba..78fbd2cc 100644 --- a/sh/profile +++ b/sh/profile @@ -10,7 +10,7 @@ for profile in "$HOME"/.profile.d/*.sh ; do done unset -v profile -# If the shell is interactive, and ~/.shrc exists, source that too -case $- in - *i*) [ -f "$HOME"/.shrc ] && . "$HOME"/.shrc ;; -esac +# If ~/.shrc exists, source that too; the test for interactivity is in there +if [ -f "$HOME"/.shrc ] ; then + source "$HOME"/.shrc +fi diff --git a/sh/shrc b/sh/shrc index e46ec2d8..3e657d4c 100644 --- a/sh/shrc +++ b/sh/shrc @@ -1,3 +1,9 @@ +# Make sure the shell is interactive +case $- in + *i*) ;; + *) return ;; +esac + # Load all the POSIX-compatible functions from ~/.shrc.d; more advanced shells # like bash will have their own functions for shrc in "$HOME"/.shrc.d/*.sh ; do -- cgit v1.2.3