aboutsummaryrefslogtreecommitdiff
path: root/bash/bashrc
diff options
context:
space:
mode:
authorTom Ryder <tom@sanctum.geek.nz>2018-11-30 14:07:45 +1300
committerTom Ryder <tom@sanctum.geek.nz>2018-11-30 14:07:45 +1300
commita2b5f3e2c173284a85401794697ba6925c74b30c (patch)
tree8b97c74ff1284e6794f855bda9fb76d31714248c /bash/bashrc
parentDrop support for Bash <= 3.0 (diff)
downloaddotfiles-a2b5f3e2c173284a85401794697ba6925c74b30c.tar.gz
dotfiles-a2b5f3e2c173284a85401794697ba6925c74b30c.zip
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.
Diffstat (limited to 'bash/bashrc')
-rw-r--r--bash/bashrc17
1 files changed, 12 insertions, 5 deletions
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:
# <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