From 75836ba0146d8e28b198ff15b875f8cf95901e35 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Tue, 2 Aug 2016 16:56:53 +1200 Subject: Slightly nicer text syntax Also remove Awk test; because Awk can do things beyond simple filtering and may do something with its arguments other than reading them, it can't really be tested like that --- test/games | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) (limited to 'test/games') diff --git a/test/games b/test/games index fc06db2f..931c3141 100755 --- a/test/games +++ b/test/games @@ -1,13 +1,23 @@ #!/bin/sh for game in games/* ; do - if sed 1q "$game" | grep -q 'bash$' ; then - bash -n "$game" || exit 1 - elif sed 1q "$game" | grep -q 'sh$' ; then - sh -n "$game" || exit 1 - elif sed 1q "$game" | grep -q 'awk -f$' ; then - "$game" /dev/null >/dev/null || exit 1 - elif sed 1q "$game" | grep -q 'sed -f$' ; then - "$game" /dev/null >/dev/null || exit 1 - fi + hb=$(sed 1q "$game") || exit + case $hb in + *bash) + bash -n "$game" || exit 1 + ;; + *sh) + sh -n "$game" || exit 1 + ;; + *'sed -f') + sed -f "$game" /dev/null >/dev/null || exit 1 + ;; + *'awk -f') + # Not sure how to test these yet + ;; + *) + printf 2>&1 'Unknown hashbang for %s\n' "$game" + exit 1 + ;; + esac done printf 'All shell scripts in games parsed successfully.\n' -- cgit v1.2.3