[OS-BUILD PATCHv2 5/20] [redhat] create_distgit_changelog.sh: Fix syntax flagged by shellcheck

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Ben Crocker <bcrocker@xxxxxxxxxx>

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@xxxxxxxxxx>
---
 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
_______________________________________________
kernel mailing list -- kernel@xxxxxxxxxxxxxxxxxxxxxxx
To unsubscribe send an email to kernel-leave@xxxxxxxxxxxxxxxxxxxxxxx
Fedora Code of Conduct: https://docs.fedoraproject.org/en-US/project/code-of-conduct/
List Guidelines: https://fedoraproject.org/wiki/Mailing_list_guidelines
List Archives: https://lists.fedoraproject.org/archives/list/kernel@xxxxxxxxxxxxxxxxxxxxxxx




[Index of Archives]     [Fedora General Discussion]     [Older Fedora Users Archive]     [Fedora Advisory Board]     [Fedora Security]     [Fedora Devel Java]     [Fedora Legacy]     [Fedora Desktop]     [ATA RAID]     [Fedora Marketing]     [Fedora Mentors]     [Fedora Package Announce]     [Fedora Package Review]     [Fedora Music]     [Fedora Packaging]     [Centos]     [Fedora SELinux]     [Coolkey]     [Yum Users]     [Tux]     [Yosemite News]     [KDE Users]     [Fedora Art]     [Fedora Docs]     [USB]     [Asterisk PBX]

  Powered by Linux