From 510cff62060da3ed639bed663ffb85311bf23707 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Thu, 14 Jan 2021 09:50:01 +0200 Subject: Add nullglob recommendation to Bash style guide --- doc/bash-style.cli | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/doc/bash-style.cli b/doc/bash-style.cli index c3e79d4..217ad11 100644 --- a/doc/bash-style.cli +++ b/doc/bash-style.cli @@ -90,6 +90,7 @@ trap \"{ cd '$owd'; exit 1; }\" ERR set -o errtrace # Trap in functions and subshells. set -o pipefail # Fail if any pipeline command fails. shopt -s lastpipe # Execute last pipeline command in the current shell. +shopt -s nullglob # Expand no-match globs to nothing rather than themselves. function info () { echo \"$*\" 1>&2; } function error () { info \"$*\"; exit 1; } @@ -231,8 +232,8 @@ option=--quiet # Option name. seds='s%^./%%' # sed script. \ -Note that quoting will inhibit globbing so you may end up with expansions -along these lines: +Take care to quote globs that are not meant to be expanded. And since quoting +will inhibit globbing, you may end up with expansions along these lines: \ rm -f \"$dir/$name\".* -- cgit v1.1