diff options
Diffstat (limited to 'bash/bashrc')
-rw-r--r-- | bash/bashrc | 27 |
1 files changed, 15 insertions, 12 deletions
diff --git a/bash/bashrc b/bash/bashrc index 8462e5c2..dcf3df53 100644 --- a/bash/bashrc +++ b/bash/bashrc @@ -6,8 +6,9 @@ esac # Don't do anything if restricted, not even sourcing the ENV file # Testing $- for "r" doesn't work -# shellcheck disable=SC2128 -[ -n "$BASH_VERSINFO" ] && shopt -q restricted_shell && return +if shopt -q restricted_shell >/dev/null 2>&1 ; then + return +fi # Clear away all aliases; we do this here rather than in the $ENV file shared # between POSIX shells, because ksh relies on aliases to implement certain @@ -16,16 +17,14 @@ unalias -a # If ENV is set, source it to get all the POSIX-compatible interactive stuff; # we should be able to do this even if we're running a truly ancient Bash -[ -n "$ENV" ] && . "$ENV" +if [ -n "$ENV" ] ; then + . "$ENV" +fi -# Ensure we're using at least version 2.05. Weird arithmetic syntax needed here -# due to leading zeroes and trailing letters in some 2.x version numbers (e.g. -# 2.05a). +# Ensure we're using at least version 3.0 # shellcheck disable=SC2128 -[ -n "$BASH_VERSINFO" ] || return -((BASH_VERSINFO[0] == 2)) && - ((10#${BASH_VERSINFO[1]%%[!0-9]*} < 5)) && - return +[ -n "$BASH_VERSINFO" ] || return # Check version array exists (>=2.0) +((BASH_VERSINFO[0] >= 3)) || return # Check actual major version number # Clear away command_not_found_handle if a system bashrc file set it up unset -f command_not_found_handle @@ -86,11 +85,15 @@ if ((BASH_VERSINFO[0] >= 4)) ; then # Warn me about stopped jobs when exiting # Available since 4.0, but only set it if >=4.1 due to bug: # <https://lists.gnu.org/archive/html/bug-bash/2009-02/msg00176.html> - ((BASH_VERSINFO[1] >= 1)) && shopt -s checkjobs + if ((BASH_VERSINFO[1] >= 1)) ; then + shopt -s checkjobs + fi # Expand variables in directory completion # Only available since 4.3 - ((BASH_VERSINFO[1] >= 3)) && shopt -s direxpand + if ((BASH_VERSINFO[1] >= 3)) ; then + shopt -s direxpand + fi fi # Load Bash-specific startup files |