shell-scripts: Use [[ instead of [ where possible

Replace all occurrences of [ with [[ in bash and zsh scripts and
configs.
Performance wise it makes sense to use the builtin instead of calling an
external command also when from a functionality stand point `test` would
suffice.
This commit is contained in:
2020-10-03 01:29:29 +02:00
parent 29d28a25ee
commit 4cb445c2b5
14 changed files with 64 additions and 64 deletions

View File

@@ -20,9 +20,9 @@ builtin local -a dirs files
# All other arguments are kept.
for arg in "$@"; do
shift
if [ -d "$arg" ]; then
if [[ -d "$arg" ]]; then
dirs+="$arg"
elif [ -e "$arg" ]; then
elif [[ -e "$arg" ]]; then
files+="$arg"
else
set -- "$@" "$arg"
@@ -36,7 +36,7 @@ fi
# Do not separate files and directories if -d flag was specified.
while getopts d flag 2>/dev/null; do
if [ "$flag" = "d" ]; then
if [[ "$flag" = "d" ]]; then
command ls "$@" -- "${files[@]}" "${dirs[@]}"
return
fi