From 3d18b4764dd3c839361c70aded843d9984410011 Mon Sep 17 00:00:00 2001 From: Lzu Tao Date: Thu, 29 Nov 2018 03:04:40 +0700 Subject: [PATCH] Prevent globbing on non-quoting variable --- programs/zstdgrep | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/programs/zstdgrep b/programs/zstdgrep index 7f050d04..a10e0710 100755 --- a/programs/zstdgrep +++ b/programs/zstdgrep @@ -103,9 +103,11 @@ EXIT_CODE=0 # call grep ... if [ "$#" -lt 1 ]; then # ... on stdin + set -f # Disable file name generation (globbing). # shellcheck disable=SC2086 "${zcat}" -fq - | "${grep}" ${grep_args} -- "${pattern}" - EXIT_CODE=$? + set +f else # ... on all files given on the command line if [ "${silent}" -lt 1 ] && [ "$#" -gt 1 ]; then @@ -113,6 +115,7 @@ else fi CUR_EXIT_CODE=0 EXIT_CODE=1 + set -f while [ "$#" -gt 0 ]; do # shellcheck disable=SC2086 "${zcat}" -fq -- "$1" | "${grep}" --label="${1}" ${grep_args} -- "${pattern}" - @@ -122,6 +125,7 @@ else fi shift done + set +f fi exit "${EXIT_CODE}"