From: Ben Crocker <bcrocker(a)redhat.com>
SC2002: Useless cat. Consider 'cmd < file | ..' or 'cmd file | ..'
instead.
SC2086: Double quote to prevent globbing and word splitting.
Signed-off-by: Ben Crocker <bcrocker(a)redhat.com>
---
redhat/scripts/create_distgit_changelog.sh | 22 ++++++++++------------
1 file changed, 10 insertions(+), 12 deletions(-)
diff --git a/redhat/scripts/create_distgit_changelog.sh
b/redhat/scripts/create_distgit_changelog.sh
index a55f4c10bdeb..1ca2bcea69da 100755
--- a/redhat/scripts/create_distgit_changelog.sh
+++ b/redhat/scripts/create_distgit_changelog.sh
@@ -12,7 +12,7 @@ tmp=$(mktemp);
function die
{
echo "Error: $1" >&2;
- rm -f $tmp;
+ rm -f "$tmp";
exit 1;
}
@@ -22,22 +22,20 @@ fi
# this expression looks for the beginning of the changelog and extracts the
# first entry
-cat $spec |
- sed -n -e '0,/%changelog/d; :abc; s/^$//; t end; p; d; N; b abc; :end; q;'
>$tmp;
+sed -n -e '0,/%changelog/d; :abc; s/^$//; t end; p; d; N; b abc; :end; q;'
"$spec" > "$tmp";
if [ ! -s "$tmp" ]; then
- die "Unabled to extract the changelog";
+ die "Unable to extract the changelog";
fi
# getting the version from the first line
-version=$(cat $tmp | head -n 1 | sed -e 's/.*\[\(.*\)\]/\1/');
+version=$(head -n 1 "$tmp" | sed -e 's/.*\[\(.*\)\]/\1/');
if [ -z "$version" ]; then
die "Unable to get version/release";
fi
# extracting the BZs to create the "Resolves" line
if [ "$zstream_flag" == "no" ]; then
- bzs=$(cat $tmp |
- grep ^- |
+ bzs=$(grep ^- "$tmp" |
sed -n -e "s/.*\[\([0-9 ]\+\)\].*/\1/p")
else
bzs=$(awk '/^-/ {
@@ -46,16 +44,16 @@ else
for(i = 1; i <= n/2; i++)
print bzs[i]
}
- }' $tmp)
+ }' "$tmp")
fi
-echo $bzs |
+echo "$bzs" |
tr ' ' '\n' |
sort -u |
tr '\n' ',' |
- sed -e "s/^/Resolves: rhbz#/; s/,\$//; s/,/, rhbz#/g;" >>$tmp;
+ sed -e "s/^/Resolves: rhbz#/; s/,\$//; s/,/, rhbz#/g;" >>
"$tmp";
echo -e "${package_name}-${version}\n"
-cat $tmp;
+cat "$tmp";
echo;
-rm -f $tmp;
+rm -f "$tmp";
--
GitLab