Skip to content

Commit 685eb65

Browse files
committed
units: store regex pattern to variable
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]>
1 parent 4d1a215 commit 685eb65

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

misc/units

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -767,9 +767,10 @@ failure_in_globing ()
767767
{
768768
# skip if globing failed, also ignore backup files
769769
local file=$1
770+
local pat='~$|\*'
770771
# use [[ if it is available in the shell implementation.
771772
if type '[[' > /dev/null 2>&1; then
772-
if [[ "$file" =~ ~$|\* ]]; then
773+
if [[ "$file" =~ $pat ]]; then
773774
return 0
774775
fi
775776
else

0 commit comments

Comments
 (0)