summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefano Lattarini <stefano.lattarini@gmail.com>2013-06-19 11:59:00 +0200
committerStefano Lattarini <stefano.lattarini@gmail.com>2013-06-19 12:10:40 +0200
commit5b4d68bc82c4fafbcf8b0580c707e0d1fd0d4c99 (patch)
tree3fa7cbe65849df3f71ee29b82c01a2d299193d12
parenta7c00e1935726a32dca6871dd0f1b7eda28d0a5b (diff)
downloadautomake-5b4d68bc82c4fafbcf8b0580c707e0d1fd0d4c99.tar.gz
rename-tests: rework some code for clarity and safety
Signed-off-by: Stefano Lattarini <stefano.lattarini@gmail.com>
-rwxr-xr-xmaintainer/rename-tests12
1 files changed, 7 insertions, 5 deletions
diff --git a/maintainer/rename-tests b/maintainer/rename-tests
index bdbd791c8..ca65e345c 100755
--- a/maintainer/rename-tests
+++ b/maintainer/rename-tests
@@ -20,6 +20,7 @@ set -e -u
me=${0##*/}
msg_file=$me.git-msg
+
fatal () { echo "$me: $*" >&2; exit 1; }
case $# in
@@ -37,15 +38,16 @@ SED=${SED-sed}
$SED --version 2>&1 | grep GNU >/dev/null 2>&1 \
|| fatal "GNU sed is required by this script"
-# Validate and cleanup input.
+# Input validation and cleanup.
input=$(
- $AWK -v me="$me" "
+ $AWK -v me="$me" '
/^#/ { next; }
(NF == 0) { next; }
- (NF != 2) { print me \": wrong number of fields at line \" NR;
+ (NF != 2) { print me ": wrong number of fields at line " NR;
exit(1); }
- { printf (\"t/%s t/%s\\n\", \$1, \$2); }
- " <<<"$input")
+ { printf ("t/%s t/%s\n", $1, $2); }
+ ' <<<"$input"
+) || exit $?
# Prepare git commit message.
exec 5>"$msg_file"