modules/programs/bash: Fix ShellCheck warnings

https://github.com/koalaman/shellcheck/wiki/SC2086
Double quote to prevent globbing and word splitting.

https://github.com/koalaman/shellcheck/wiki/SC2166
Prefer `[ p ] && [ q ]` as `[ p -a q ]` is not well defined.

https://github.com/koalaman/shellcheck/wiki/SC2219
Instead of `let expr`, prefer `(( expr ))` .

Signed-off-by: Anders Kaseorg <andersk@mit.edu>

Changed files
+5 -5
nixos
modules
+1 -1
nixos/modules/programs/bash/bash-completion.nix
···
shopt -s nullglob
for p in $NIX_PROFILES; do
for m in "$p/etc/bash_completion.d/"*; do
-
. $m
+
. "$m"
done
done
eval "$nullglobStatus"
+4 -4
nixos/modules/programs/bash/bash.nix
···
promptInit = mkOption {
default = ''
# Provide a nice prompt if the terminal supports it.
-
if [ "$TERM" != "dumb" -o -n "$INSIDE_EMACS" ]; then
+
if [ "$TERM" != "dumb" ] || [ -n "$INSIDE_EMACS" ]; then
PROMPT_COLOR="1;31m"
-
let $UID && PROMPT_COLOR="1;32m"
-
if [ -n "$INSIDE_EMACS" -o "$TERM" == "eterm" -o "$TERM" == "eterm-color" ]; then
+
((UID)) && PROMPT_COLOR="1;32m"
+
if [ -n "$INSIDE_EMACS" ] || [ "$TERM" = "eterm" ] || [ "$TERM" = "eterm-color" ]; then
# Emacs term mode doesn't support xterm title escape sequence (\e]0;)
PS1="\n\[\033[$PROMPT_COLOR\][\u@\h:\w]\\$\[\033[0m\] "
else
···
# /etc/bashrc: DO NOT EDIT -- this file has been generated automatically.
# Only execute this file once per shell.
-
if [ -n "$__ETC_BASHRC_SOURCED" -o -n "$NOSYSBASHRC" ]; then return; fi
+
if [ -n "$__ETC_BASHRC_SOURCED" ] || [ -n "$NOSYSBASHRC" ]; then return; fi
__ETC_BASHRC_SOURCED=1
# If the profile was not loaded in a parent process, source