From a2b5f3e2c173284a85401794697ba6925c74b30c Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Fri, 30 Nov 2018 14:07:45 +1300 Subject: Use ||/&& short-circuiting only for flow control If we're doing something besides return/exit, it should be a proper `if` condition so that the semantics are clearer. --- bash/bashrc | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) (limited to 'bash/bashrc') diff --git a/bash/bashrc b/bash/bashrc index 06cbb6b3..e8348317 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,7 +17,9 @@ 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 3.0. [ -n "$BASH_VERSINFO" ] || return @@ -81,11 +84,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: # - ((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 -- cgit v1.2.3