From a94cc10f72bbb998789bf4e835fb2a509a92da28 Mon Sep 17 00:00:00 2001 From: Anthony Perkins Date: Tue, 23 Aug 2022 13:13:40 +0100 Subject: [PATCH] Load shrc files if the shell is interactive --- roles/home-cli/files/bash_profile | 7 +++++++ roles/home-cli/files/bashrc | 9 +++++++++ roles/home-cli/files/shrc | 23 +++++++++++++++-------- roles/home-cli/files/zprofile | 11 +++++++++-- roles/home-cli/files/zshrc | 9 +++++++++ 5 files changed, 49 insertions(+), 10 deletions(-) diff --git a/roles/home-cli/files/bash_profile b/roles/home-cli/files/bash_profile index 48fa744..ba5adab 100644 --- a/roles/home-cli/files/bash_profile +++ b/roles/home-cli/files/bash_profile @@ -6,7 +6,14 @@ fi export BASH_ENV="$HOME/.bashrc" +export _acp_ignore_shrc=1 if [ -r "$HOME/.profile" ] then . "$HOME/.profile" fi +unset _acp_ignore_shrc + +if [ -r "$HOME/.bashrc" ] +then + . "$HOME/.bashrc" +fi diff --git a/roles/home-cli/files/bashrc b/roles/home-cli/files/bashrc index 3a7ae4a..6de9abe 100644 --- a/roles/home-cli/files/bashrc +++ b/roles/home-cli/files/bashrc @@ -1,4 +1,13 @@ #!/bin/bash +case "$-" in +*i*) + ;; +*) + # Shell is not interactive. + return 1 + ;; +esac + if [ -f /etc/bashrc ] then . /etc/bashrc diff --git a/roles/home-cli/files/shrc b/roles/home-cli/files/shrc index 5f242c6..6e9227b 100644 --- a/roles/home-cli/files/shrc +++ b/roles/home-cli/files/shrc @@ -1,4 +1,18 @@ #!/bin/sh +if [ -n "$_acp_ignore_shrc" ] +then + return 1 +fi + +case "$-" in +*i*) + ;; +*) + # Shell is not interactive. + return 1 + ;; +esac + if [ -d /var/acp ] then export ACP=/var/acp @@ -294,11 +308,4 @@ tlscheck () { fi } -case "$-" in -*i*) - # Shell is interactive - usermotd - ;; -*) - ;; -esac +usermotd diff --git a/roles/home-cli/files/zprofile b/roles/home-cli/files/zprofile index 80038c0..b1ea3c5 100644 --- a/roles/home-cli/files/zprofile +++ b/roles/home-cli/files/zprofile @@ -4,7 +4,14 @@ then . /etc/zprofile fi -if [ -e $HOME/.profile ] +export _acp_ignore_shrc=1 +if [ -r "$HOME/.profile" ] then - emulate sh -c ". $HOME/.profile" + emulate sh -c '. "$HOME/.profile"' +fi +unset _acp_ignore_shrc + +if [ -r "$HOME/.zshrc" ] +then + . "$HOME/.zshrc" fi diff --git a/roles/home-cli/files/zshrc b/roles/home-cli/files/zshrc index 7772c80..872b2a2 100644 --- a/roles/home-cli/files/zshrc +++ b/roles/home-cli/files/zshrc @@ -1,4 +1,13 @@ #!/bin/zsh +case "$-" in +*i*) + ;; +*) + # Shell is not interactive. + return 1 + ;; +esac + if [ -f /etc/zshrc ] then . /etc/zshrc