From 5a00df4a77ea5453ce7b63aee2396b935dc58ed2 Mon Sep 17 00:00:00 2001 From: Dean Wilson Date: Sun, 10 Apr 2016 06:45:26 -0400 Subject: [PATCH] Protect some shell expansions and do a general tidy up. Heavily inspired by a PR from @mvk --- puppet-ls | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/puppet-ls b/puppet-ls index cc3172c..b795303 100755 --- a/puppet-ls +++ b/puppet-ls @@ -1,5 +1,5 @@ #!/bin/bash -# tested on 0.25 +# tested on 0.25 and 3.8.4 usage () { @@ -39,12 +39,12 @@ exit 0 ################################################################# appname=$(basename "$0") -comm="comm -12" +comm='comm -12' -while getopts "irRh" option +while getopts 'irRh' option do case $option in - i ) comm="comm -13" ;; + i ) comm='comm -13' ;; r ) recursive=1 ;; R ) follow_links=1 ;; h ) usage ;; @@ -53,7 +53,7 @@ case $option in done # grab the non-getopts option -shift $(($OPTIND - 1)) +shift $((OPTIND - 1)) target="${1-$(pwd)}" target="${target%/}" @@ -72,8 +72,8 @@ else vardir='/var/lib/puppet' fi -catalog_filelist=$(mktemp -q /tmp/$appname.XXXXXX) -lister_filelist=$(mktemp -q /tmp/$appname.XXXXXX) +catalog_filelist=$(mktemp -q "/tmp/$appname.XXXXXX") +lister_filelist=$(mktemp -q "/tmp/$appname.XXXXXX") # better clean up trap "rm -f $catalog_filelist $lister_filelist" 0 1 2 15 @@ -82,8 +82,8 @@ trap "rm -f $catalog_filelist $lister_filelist" 0 1 2 15 ( grep -h "title: /" "$vardir/state/last_run_report.yaml" | awk '{ print $NF }' ; sed -e '/File\[/!d' -e 's/File\[//' -e 's/\]://' -e 's/ //g' < /var/lib/puppet/state/state.yaml -) | sort > $catalog_filelist +) | sort > "$catalog_filelist" -$lister | sort > $lister_filelist +$lister | sort > "$lister_filelist" -$comm $catalog_filelist $lister_filelist +$comm "$catalog_filelist" "$lister_filelist"