summaryrefslogtreecommitdiff
path: root/tests/misc
diff options
context:
space:
mode:
authorPádraig Brady <P@draigBrady.com>2015-11-01 18:53:26 +0000
committerPádraig Brady <P@draigBrady.com>2015-11-04 23:30:14 +0000
commit08e8fd7e38f2dae7c69c54eb22d508b6517e66e5 (patch)
tree63d021e305cd93bea445f9484fe8b3446dda2c3d /tests/misc
parent1e8f9afac53a628dbc64e62bea53eb2da29c47fa (diff)
downloadcoreutils-08e8fd7e38f2dae7c69c54eb22d508b6517e66e5.tar.xz
all: avoid quoting file names when possible
Quote file names using the "shell-escape" or "shell-escape-always" methods, which quote as appropriate for most shells, and better support copy and paste of presented names. The "always" variant is used when the file name is embedded in an error message with surrounding spaces. * cfg.mk (sc_error_shell_quotes): A new syntax check rule to suggest quotef() where appropriate. (sc_error_shell_always_quotes): Likewise for quoteaf(). * src/system.h (quotef): A new define to apply shell quoting when needed. I.E. when shell character or ':' is present. (quoteaf): Likewise, but always quote. * src/*.c: Use quotef() and quoteaf() rather than quote() where appropriate. * tests/: Adjust accordingly.
Diffstat (limited to 'tests/misc')
-rwxr-xr-xtests/misc/dircolors.pl2
-rwxr-xr-xtests/misc/ls-misc.pl8
-rwxr-xr-xtests/misc/md5sum.pl10
-rwxr-xr-xtests/misc/readlink-fp-loop.sh6
-rwxr-xr-xtests/misc/sha1sum.pl6
-rwxr-xr-xtests/misc/shred-passes.sh64
-rwxr-xr-xtests/misc/sort-files0-from.pl6
-rwxr-xr-xtests/misc/sort.pl4
-rwxr-xr-xtests/misc/tsort.pl6
-rwxr-xr-xtests/misc/wc-files0-from.pl8
10 files changed, 60 insertions, 60 deletions
diff --git a/tests/misc/dircolors.pl b/tests/misc/dircolors.pl
index 2ef6228de..2e6f27d88 100755
--- a/tests/misc/dircolors.pl
+++ b/tests/misc/dircolors.pl
@@ -26,7 +26,7 @@ use strict;
my @Tests =
(
['a', '-b', {IN => {k => "exec\n"}},
- {ERR => "dircolors: 'k':1: invalid line; missing second token\n"},
+ {ERR => "dircolors: k:1: invalid line; missing second token\n"},
{EXIT => 1}],
['quote', '-b', {IN => "exec 'echo Hello;:'\n"},
{OUT => "LS_COLORS='ex='\\''echo Hello;\\:'\\'':';\n"
diff --git a/tests/misc/ls-misc.pl b/tests/misc/ls-misc.pl
index f88c7a8ea..007e25787 100755
--- a/tests/misc/ls-misc.pl
+++ b/tests/misc/ls-misc.pl
@@ -235,7 +235,7 @@ my @Tests =
{POST => sub {unlink 'd/s' or die "d/s: $!\n";
rmdir 'd' or die "d: $!\n";
restore_ls_colors; }},
- {ERR => "ls: cannot access d/s: No such file or directory\n"},
+ {ERR => "ls: cannot access 'd/s': No such file or directory\n"},
{EXIT => 1}
],
# Related to the above fix, is this case where
@@ -289,7 +289,7 @@ my @Tests =
# From Stéphane Chazelas.
['no-a-isdir-b', 'no-dir d',
{OUT => "d:\n"},
- {ERR => "ls: cannot access no-dir: No such file or directory\n"},
+ {ERR => "ls: cannot access 'no-dir': No such file or directory\n"},
$mkdir, $rmdir, {EXIT => 2}],
['recursive-2', '-R d', {OUT => "d:\ne\n\nd/e:\n"}, $mkdir2, $rmdir2],
@@ -327,8 +327,8 @@ my @Tests =
# at least one of which is a nonempty directory.
['multi-arg-U1', '-U1 d no-such',
{OUT => "d:\nf\n"},
- {ERR_SUBST=>'s/ch:.*/ch:/'},
- {ERR => "$prog: cannot access no-such:\n"},
+ {ERR_SUBST=>"s/ch':.*/ch':/"},
+ {ERR => "$prog: cannot access 'no-such':\n"},
$mkdir_reg,
$rmdir_reg,
{EXIT => 2},
diff --git a/tests/misc/md5sum.pl b/tests/misc/md5sum.pl
index c99658213..ad1896d53 100755
--- a/tests/misc/md5sum.pl
+++ b/tests/misc/md5sum.pl
@@ -92,7 +92,7 @@ my @Tests =
. "invalid\n" }},
{AUX=> {f=> 'foo'}},
{OUT=>"f: FAILED\nf: FAILED\n"},
- {ERR=>"md5sum: 'f.md5': 3: "
+ {ERR=>"md5sum: f.md5: 3: "
. "improperly formatted MD5 checksum line\n"
. "md5sum: WARNING: 1 line is improperly formatted\n"
. "md5sum: WARNING: 2 computed checksums did NOT match\n"},
@@ -102,7 +102,7 @@ my @Tests =
# sha1sum accept BSD format.
['check-bsd', '--check', {IN=> {'f.sha1' => "SHA1 (f) = $degenerate\n"}},
{AUX=> {f=> ''}},
- {ERR=>"md5sum: 'f.sha1': no properly formatted "
+ {ERR=>"md5sum: f.sha1: no properly formatted "
. "MD5 checksum lines found\n"},
{EXIT=> 1}],
['check-bsd2', '--check', {IN=> {'f.md5' => "MD5 (f) = $degenerate\n"}},
@@ -112,7 +112,7 @@ my @Tests =
{AUX=> {f=> 'bar'}}, {EXIT=> 1}],
['check-openssl', '--check', {IN=> {'f.sha1' => "SHA1(f)= $degenerate\n"}},
{AUX=> {f=> ''}},
- {ERR=>"md5sum: 'f.sha1': no properly formatted "
+ {ERR=>"md5sum: f.sha1: no properly formatted "
. "MD5 checksum lines found\n"},
{EXIT=> 1}],
['check-openssl2', '--check', {IN=> {'f.md5' => "MD5(f)= $degenerate\n"}},
@@ -121,7 +121,7 @@ my @Tests =
{IN=> {'f.md5' => "MD5(f)= $degenerate\n"}},
{AUX=> {f=> 'bar'}}, {EXIT=> 1}],
['bsd-segv', '--check', {IN=> {'z' => "MD5 ("}}, {EXIT=> 1},
- {ERR=> "$prog: 'z': no properly formatted MD5 checksum lines found\n"}],
+ {ERR=> "$prog: z: no properly formatted MD5 checksum lines found\n"}],
# Ensure that when there's a NUL byte among the checksum hex digits
# we detect the invalid formatting and don't even open the file.
@@ -129,7 +129,7 @@ my @Tests =
# h: FAILED
# md5sum: WARNING: 1 of 1 computed checksum did NOT match
['nul-in-cksum', '--check', {IN=> {'h'=>("\0"x32)." h\n"}}, {EXIT=> 1},
- {ERR=> "$prog: 'h': no properly formatted MD5 checksum lines found\n"}],
+ {ERR=> "$prog: h: no properly formatted MD5 checksum lines found\n"}],
);
# Insert the '--text' argument for each test.
diff --git a/tests/misc/readlink-fp-loop.sh b/tests/misc/readlink-fp-loop.sh
index d3e1a1eaf..50ada55e8 100755
--- a/tests/misc/readlink-fp-loop.sh
+++ b/tests/misc/readlink-fp-loop.sh
@@ -42,10 +42,10 @@ ln -sf ../s/1 d/2 || framework_failure_
readlink -v -e p/1 2> out && fail=1
readlink_msg=$(cat out)
case $readlink_msg in
- "readlink: 'p/1': "*) ;;
+ "readlink: p/1: "*) ;;
*) fail=1;;
esac
-symlink_loop_msg=${readlink_msg#"readlink: 'p/1': "}
+symlink_loop_msg=${readlink_msg#"readlink: p/1: "}
# Exercise the hash table code.
ln -nsf ../s/3 d/2 || framework_failure_
@@ -62,7 +62,7 @@ compare exp out || fail=1
# A trivial loop
ln -s loop loop
readlink -v -e loop 2> out && fail=1
-echo "readlink: 'loop': $symlink_loop_msg" > exp || framework_failure_
+echo "readlink: loop: $symlink_loop_msg" > exp || framework_failure_
compare exp out || fail=1
Exit $fail
diff --git a/tests/misc/sha1sum.pl b/tests/misc/sha1sum.pl
index b58a7f4a1..de923b636 100755
--- a/tests/misc/sha1sum.pl
+++ b/tests/misc/sha1sum.pl
@@ -53,7 +53,7 @@ my @Tests =
# md5sum accept BSD format.
['check-bsd', '--check', {IN=> {'f.md5' => "MD5 (f) = $sha_degenerate\n"}},
{AUX=> {f=> ''}},
- {ERR=>"sha1sum: 'f.md5': no properly formatted "
+ {ERR=>"sha1sum: f.md5: no properly formatted "
. "SHA1 checksum lines found\n"},
{EXIT=> 1}],
['check-bsd2', '--check',
@@ -65,7 +65,7 @@ my @Tests =
['check-openssl', '--check',
{IN=> {'f.md5' => "MD5(f)= $sha_degenerate\n"}},
{AUX=> {f=> ''}},
- {ERR=>"sha1sum: 'f.md5': no properly formatted "
+ {ERR=>"sha1sum: f.md5: no properly formatted "
. "SHA1 checksum lines found\n"},
{EXIT=> 1}],
['check-openssl2', '--check',
@@ -75,7 +75,7 @@ my @Tests =
{IN=> {'f.sha1' => "SHA1(f)= $sha_degenerate\n"}},
{AUX=> {f=> 'bar'}}, {EXIT=> 1}],
['bsd-segv', '--check', {IN=> {'z' => "SHA1 ("}}, {EXIT=> 1},
- {ERR=> "$prog: 'z': no properly formatted SHA1 checksum lines found\n"}],
+ {ERR=> "$prog: z: no properly formatted SHA1 checksum lines found\n"}],
);
# Insert the '--text' argument for each test.
diff --git a/tests/misc/shred-passes.sh b/tests/misc/shred-passes.sh
index ddf788b05..64216fd8a 100755
--- a/tests/misc/shred-passes.sh
+++ b/tests/misc/shred-passes.sh
@@ -24,12 +24,12 @@ print_ver_ shred
# 3 random passes and a single rename.
printf 1 > f || framework_failure_
echo "\
-shred: 'f': pass 1/3 (random)...
-shred: 'f': pass 2/3 (random)...
-shred: 'f': pass 3/3 (random)...
-shred: 'f': removing
-shred: 'f': renamed to 0
-shred: 'f': removed" > exp || framework_failure_
+shred: f: pass 1/3 (random)...
+shred: f: pass 2/3 (random)...
+shred: f: pass 3/3 (random)...
+shred: f: removing
+shred: f: renamed to 0
+shred: f: removed" > exp || framework_failure_
shred -v -u f 2>out || fail=1
compare exp out || fail=1
@@ -39,9 +39,9 @@ compare exp out || fail=1
# to bypass the data passes
touch f || framework_failure_
echo "\
-shred: 'f': removing
-shred: 'f': renamed to 0
-shred: 'f': removed" > exp || framework_failure_
+shred: f: removing
+shred: f: renamed to 0
+shred: f: removed" > exp || framework_failure_
shred -v -u f 2>out || fail=1
compare exp out || fail=1
@@ -52,29 +52,29 @@ compare exp out || fail=1
dd bs=100K count=1 if=/dev/zero | tr '\0' 'U' > Us || framework_failure_
printf 1 > f || framework_failure_
echo "\
-shred: 'f': pass 1/20 (random)...
-shred: 'f': pass 2/20 (ffffff)...
-shred: 'f': pass 3/20 (924924)...
-shred: 'f': pass 4/20 (888888)...
-shred: 'f': pass 5/20 (db6db6)...
-shred: 'f': pass 6/20 (777777)...
-shred: 'f': pass 7/20 (492492)...
-shred: 'f': pass 8/20 (bbbbbb)...
-shred: 'f': pass 9/20 (555555)...
-shred: 'f': pass 10/20 (aaaaaa)...
-shred: 'f': pass 11/20 (random)...
-shred: 'f': pass 12/20 (6db6db)...
-shred: 'f': pass 13/20 (249249)...
-shred: 'f': pass 14/20 (999999)...
-shred: 'f': pass 15/20 (111111)...
-shred: 'f': pass 16/20 (000000)...
-shred: 'f': pass 17/20 (b6db6d)...
-shred: 'f': pass 18/20 (eeeeee)...
-shred: 'f': pass 19/20 (333333)...
-shred: 'f': pass 20/20 (random)...
-shred: 'f': removing
-shred: 'f': renamed to 0
-shred: 'f': removed" > exp || framework_failure_
+shred: f: pass 1/20 (random)...
+shred: f: pass 2/20 (ffffff)...
+shred: f: pass 3/20 (924924)...
+shred: f: pass 4/20 (888888)...
+shred: f: pass 5/20 (db6db6)...
+shred: f: pass 6/20 (777777)...
+shred: f: pass 7/20 (492492)...
+shred: f: pass 8/20 (bbbbbb)...
+shred: f: pass 9/20 (555555)...
+shred: f: pass 10/20 (aaaaaa)...
+shred: f: pass 11/20 (random)...
+shred: f: pass 12/20 (6db6db)...
+shred: f: pass 13/20 (249249)...
+shred: f: pass 14/20 (999999)...
+shred: f: pass 15/20 (111111)...
+shred: f: pass 16/20 (000000)...
+shred: f: pass 17/20 (b6db6d)...
+shred: f: pass 18/20 (eeeeee)...
+shred: f: pass 19/20 (333333)...
+shred: f: pass 20/20 (random)...
+shred: f: removing
+shred: f: renamed to 0
+shred: f: removed" > exp || framework_failure_
shred -v -u -n20 --random-source=Us f 2>out || fail=1
compare exp out || fail=1
diff --git a/tests/misc/sort-files0-from.pl b/tests/misc/sort-files0-from.pl
index 6773309d1..63c5bb3e4 100755
--- a/tests/misc/sort-files0-from.pl
+++ b/tests/misc/sort-files0-from.pl
@@ -55,14 +55,14 @@ my @Tests =
# one NUL
['nul-1', '--files0-from=-', '<', {IN=>"\0"}, {EXIT=>2},
- {ERR => "$prog: '-':1: invalid zero-length file name\n"}],
+ {ERR => "$prog: -:1: invalid zero-length file name\n"}],
# two NULs
# Note that the behavior here differs from 'wc' in that the
# first zero-length file name is treated as fatal, so there
# is only one line of diagnostic output.
['nul-2', '--files0-from=-', '<', {IN=>"\0\0"}, {EXIT=>2},
- {ERR => "$prog: '-':1: invalid zero-length file name\n"}],
+ {ERR => "$prog: -:1: invalid zero-length file name\n"}],
# one file name, no NUL
['1', '--files0-from=-', '<',
@@ -86,7 +86,7 @@ my @Tests =
# should be no output on STDOUT.
['zero-len', '--files0-from=-', '<',
{IN=>{f=>"\0g\0"}}, {AUX=>{g=>''}},
- {ERR => "$prog: '-':1: invalid zero-length file name\n"}, {EXIT=>2} ],
+ {ERR => "$prog: -:1: invalid zero-length file name\n"}, {EXIT=>2} ],
);
my $save_temps = $ENV{DEBUG};
diff --git a/tests/misc/sort.pl b/tests/misc/sort.pl
index 012d8b94e..f6a222c2c 100755
--- a/tests/misc/sort.pl
+++ b/tests/misc/sort.pl
@@ -33,7 +33,7 @@ my $mb_locale = $ENV{LOCALE_FR_UTF8};
# Normalize each diagnostic to use '-'.
my $normalize_filename = {ERR_SUBST => 's/^$prog: .*?:/$prog: -:/'};
-my $no_file = "$prog: cannot read: 'no-file': No such file or directory\n";
+my $no_file = "$prog: cannot read: no-file: No such file or directory\n";
my @Tests =
(
@@ -327,7 +327,7 @@ my @Tests =
["o-no-file1", qw(-o no-file no-file), {EXIT=>2}, {ERR=>$no_file}],
["create-empty", qw(-o no/such/file /dev/null), {EXIT=>2},
- {ERR=>"$prog: open failed: 'no/such/file': No such file or directory\n"}],
+ {ERR=>"$prog: open failed: no/such/file: No such file or directory\n"}],
# From Paul Eggert. This was fixed in textutils-1.22k.
["neg-nls", '-n', {IN=>"-1\n-9\n"}, {OUT=>"-9\n-1\n"}],
diff --git a/tests/misc/tsort.pl b/tests/misc/tsort.pl
index 60f22c43c..4d04866ad 100755
--- a/tests/misc/tsort.pl
+++ b/tests/misc/tsort.pl
@@ -27,10 +27,10 @@ my @Tests =
(
['cycle-1', {IN => {f => "t b\nt s\ns t\n"}}, {OUT => "s\nt\nb\n"},
{EXIT => 1},
- {ERR => "tsort: 'f': input contains a loop:\ntsort: s\ntsort: t\n"} ],
+ {ERR => "tsort: f: input contains a loop:\ntsort: s\ntsort: t\n"} ],
['cycle-2', {IN => {f => "t x\nt s\ns t\n"}}, {OUT => "s\nt\nx\n"},
{EXIT => 1},
- {ERR => "tsort: 'f': input contains a loop:\ntsort: s\ntsort: t\n"} ],
+ {ERR => "tsort: f: input contains a loop:\ntsort: s\ntsort: t\n"} ],
['posix-1', {IN => "a b c c d e\ng g\nf g e f\nh h\n"},
{OUT => "a\nc\nd\nh\nb\ne\nf\ng\n"}],
@@ -50,7 +50,7 @@ my @Tests =
# copy of the final token were appended.
['odd', {IN => "a\n"},
{EXIT => 1},
- {ERR => "tsort: 'odd.1': input contains an odd number of tokens\n"}],
+ {ERR => "tsort: odd.1: input contains an odd number of tokens\n"}],
['only-one', {IN => {f => ""}}, {IN => {g => ""}},
{EXIT => 1},
diff --git a/tests/misc/wc-files0-from.pl b/tests/misc/wc-files0-from.pl
index 519587be6..cae3fc225 100755
--- a/tests/misc/wc-files0-from.pl
+++ b/tests/misc/wc-files0-from.pl
@@ -53,13 +53,13 @@ my @Tests =
# one NUL
['nul-1', '--files0-from=-', '<', {IN=>"\0"}, {EXIT=>1},
- {ERR => "$prog: '-':1: invalid zero-length file name\n"}],
+ {ERR => "$prog: -:1: invalid zero-length file name\n"}],
# two NULs
['nul-2', '--files0-from=-', '<', {IN=>"\0\0"}, {EXIT=>1},
{OUT=>"0 0 0 total\n"},
- {ERR => "$prog: '-':1: invalid zero-length file name\n"
- . "$prog: '-':2: invalid zero-length file name\n"}],
+ {ERR => "$prog: -:1: invalid zero-length file name\n"
+ . "$prog: -:2: invalid zero-length file name\n"}],
# one file name, no NUL
['1', '--files0-from=-', '<',
@@ -83,7 +83,7 @@ my @Tests =
['zero-len', '--files0-from=-', '<',
{IN=>{f=>"\0g\0"}}, {AUX=>{g=>''}},
{OUT=>"0 0 0 g\n0 0 0 total\n"},
- {ERR => "$prog: '-':1: invalid zero-length file name\n"}, {EXIT=>1} ],
+ {ERR => "$prog: -:1: invalid zero-length file name\n"}, {EXIT=>1} ],
);
my $save_temps = $ENV{DEBUG};