diff options
author | Benjamin Barenblat <bbaren@google.com> | 2019-09-20 09:06:07 -0400 |
---|---|---|
committer | Benjamin Barenblat <bbaren@google.com> | 2019-09-20 09:06:07 -0400 |
commit | a80f05dfd7ec9bffc17d0c30309385eda9dadf6d (patch) | |
tree | 79973a3db1d938da711acb6f8ae144f26b4d52bf /sor | |
parent | d560d7ec4bf87a9f9dd2f7135489b26db5f9fb4b (diff) |
sor: Use less quoting
Remove quotes around variable expansions that are guaranteed safe.
Diffstat (limited to 'sor')
-rwxr-xr-x | sor | 24 |
1 files changed, 12 insertions, 12 deletions
@@ -34,32 +34,32 @@ ask_for_help() { } read_filename() { - local null_terminate="$1" - local target_var="$2" - if [ "$null_terminate" = "true" ]; then - IFS= read -r -d '' "$target_var" + local null_terminate=$1 + local target_var=$2 + if [ $null_terminate = true ]; then + IFS= read -r -d '' $target_var else - read "$target_var" + read $target_var fi } print_filename() { - local null_terminate="$1" + local null_terminate=$1 local filename="$2" - if [ "$null_terminate" = "true" ]; then + if [ $null_terminate = true ]; then printf '%s\0' "$filename" else echo "$filename" fi } -if ! temp=$(getopt -s bash -n sor -o '0' -l null,help -- "$@"); then +if ! temp=$(getopt -s bash -n sor -o 0 -l null,help -- "$@"); then ask_for_help >&2 exit 1 fi eval set -- "$temp" unset temp -null_terminate="false" +null_terminate=false while true; do case "$1" in --help) @@ -68,7 +68,7 @@ while true; do ;; -0|--null) shift - null_terminate="true" + null_terminate=true ;; --) shift @@ -81,10 +81,10 @@ while true; do esac done -while read_filename "$null_terminate" file; do +while read_filename $null_terminate file; do for test in "$@"; do if eval "$test \"$file\""; then - print_filename "$null_terminate" "$file" + print_filename $null_terminate "$file" continue 2 fi done |