]> git.draconx.ca Git - cdecl99.git/commitdiff
tests: Avoid backslashes in awk variable assignment.
authorNick Bowler <nbowler@draconx.ca>
Sat, 27 Jan 2024 02:40:11 +0000 (21:40 -0500)
committerNick Bowler <nbowler@draconx.ca>
Sat, 27 Jan 2024 03:35:03 +0000 (22:35 -0500)
Backslashes in awk command-line variable assignments are normally
interpreted as beginning escape sequences, which is not what we
want to do for the error message prefix test.

Just exchanging backslashes with some other character (let's pick
forward slashes) should be more than sufficient for this test, to
ensure that the program name prefixes error messages.

tests/general.at

index a77134f04310086a04159df468bd6ffeeb1fa1ec..fd48b062fd49b1c7fa9fbb5eed108d0c3a0244ce 100644 (file)
@@ -116,7 +116,7 @@ AT_SETUP([cdecl99 command error messages])
 # This will only get the start of progname if it includes spaces;
 # so we won't worry too hard about the exact format later.
 AT_CHECK([LC_ALL=C cdecl99 --help], [0], [stdout])
-progname=`$AWK 'NR == 1 { print $2; }' stdout`dnl'
+progname=`$AWK 'NR == 1 { gsub(/[[\\\\]]/, "/", $2); print $2; }' stdout`dnl'
 
 # every line is erroneous
 AT_DATA([input],
@@ -128,6 +128,7 @@ bad command
 
 AT_DATA([check.awk],
 [[BEGIN { status=0; }
+{ gsub(/[\\]/, "/"); }
 $1 == progname || $1 == (progname ":") { next; }
 { status=1; print "unprefixed message on line", NR ":", $0; }
 END { exit(status); }