Skip to content
This repository has been archived by the owner on Oct 16, 2019. It is now read-only.

Commit

Permalink
Protect some shell expansions and do a general tidy up.
Browse files Browse the repository at this point in the history
Heavily inspired by a PR from @mvk
  • Loading branch information
deanwilson committed Apr 10, 2016
1 parent 7bc2b49 commit 5a00df4
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions puppet-ls
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/bin/bash
# tested on 0.25
# tested on 0.25 and 3.8.4

usage () {

Expand Down Expand Up @@ -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 ;;
Expand All @@ -53,7 +53,7 @@ case $option in
done

# grab the non-getopts option
shift $(($OPTIND - 1))
shift $((OPTIND - 1))
target="${1-$(pwd)}"
target="${target%/}"

Expand All @@ -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
Expand All @@ -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"

0 comments on commit 5a00df4

Please sign in to comment.