Skip to content

Commit

Permalink
units: store regex pattern to variable
Browse files Browse the repository at this point in the history
zsh expects the operand of =~ operator inside [[ ... ]] to be quoted.
bash doesn't.

To fill the gap between zsh and bash, this change stores the
regex pattern to a variable, and refers the variable as
the operand.

Signed-off-by: Masatake YAMATO <[email protected]>
  • Loading branch information
masatake committed Oct 23, 2019
1 parent 4d1a215 commit 685eb65
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion misc/units
Original file line number Diff line number Diff line change
Expand Up @@ -767,9 +767,10 @@ failure_in_globing ()
{
# skip if globing failed, also ignore backup files
local file=$1
local pat='~$|\*'
# use [[ if it is available in the shell implementation.
if type '[[' > /dev/null 2>&1; then
if [[ "$file" =~ ~$|\* ]]; then
if [[ "$file" =~ $pat ]]; then
return 0
fi
else
Expand Down

0 comments on commit 685eb65

Please sign in to comment.