Per ottenere /bin/sh per eseguire ~/.bashrc allo stesso modo di /bin/bash , dovresti fare quanto segue.
-
Aggiungi le seguenti righe a ~/.profile .
LOGINSHELL=YES
export ENV=~/.shrc
-
Crea il file ~/.shrc contenente la seguente riga.
if [ "$LOGINSHELL" != "YES" ]; then source ~/.bashrc; fi
Per facilitare il debug, di solito aggiungo la seguente riga all'inizio del file ~/.profile .
export DEBUGSHELL=YES
Questa riga può essere commentata quando si esegue il debug, come mostrato sotto.
#export DEBUGSHELL=YES
Successivamente, aggiungi le istruzioni condizionali echo all'inizio e alla fine dei file come ~/.profile , ~/.bashrc , ~/.shrc e altri. Ad esempio, ~/.shrc conterrà quanto segue.
if [ "$DEBUGSHELL" = "YES" ]; then echo entered .shrc; fi
if [ "$LOGINSHELL" != "YES" ]; then source ~/.bashrc; fi
if [ "$DEBUGSHELL" = "YES" ]; then echo exited .shrc; fi
Un'altra idea, che può essere utile, è creare un file ~/.bashcm per contenere i comandi che devono essere eseguiti per entrambe le shell di login e interattive. Ad esempio, questo di solito è dove metto i miei comandi alias . Dovrai inoltre includere la seguente riga in entrambi i file ~/.profile e ~/.bashrc .
source ~/.bashcm