The first thing in my bashrc file is this expression:
# If not running interactively, don't do anything
case $- in
*i*) ;;
*) return;;
esac
Can somebody explain what this means?
all these symbols make it really hard to google, and there is no Haskell "hoogle" equivalent for bash so I can search for symbol expressions.
The intended behavior seems to be similar to this.
nonsourced=0;
# if sourced,
if [[ "$0" == "$BASH_SOURCE" ]]; then
nonsourced=1;
else
nonsourced=0;
fi
echo "nonsourced? $nonsourced";
case $- in
*i*)
# this case is entered if "$-" contains "i".
if [[ "$nonsourced" -eq "0" ]]; then
echo "1. " "$-";
fi
;; # leave case?
*) # this case is entered in all other cases.
if [[ "$nonsourced" -eq "0" ]]; then
echo "2. " "$-";
return
else
# cannot return from nonsourced, use exit.
echo "avoided return from nonsourced #2";
exit 0;
fi
;; # leave case?
esac
echo "3";