summaryrefslogtreecommitdiff
path: root/tests/misc/shuf.sh
diff options
context:
space:
mode:
authorPádraig Brady <P@draigBrady.com>2013-03-27 11:06:00 +0000
committerPádraig Brady <P@draigBrady.com>2013-04-04 02:55:55 +0100
commitf7867e73caac82349e5623d04e46aaf784778644 (patch)
tree6a08f079b9829745b107d3972e762138dacc2ec5 /tests/misc/shuf.sh
parent34023817cb0225b50779a546a58e057e5e920d2c (diff)
downloadcoreutils-f7867e73caac82349e5623d04e46aaf784778644.tar.xz
shuf: exit without reading if would never output
* src/shuf.c (main): If -n0 specified then no data would ever be output, so exit without reading input. * tests/misc/shuf.sh: Augment the related test with this case.
Diffstat (limited to 'tests/misc/shuf.sh')
-rwxr-xr-xtests/misc/shuf.sh6
1 files changed, 6 insertions, 0 deletions
diff --git a/tests/misc/shuf.sh b/tests/misc/shuf.sh
index 9c9526d4d..171b25a1f 100755
--- a/tests/misc/shuf.sh
+++ b/tests/misc/shuf.sh
@@ -57,4 +57,10 @@ cmp out exp || { fail=1; echo "missing NUL terminator?" 1>&2; }
timeout 10 shuf -i1-$SIZE_MAX -n2 >/dev/null ||
{ fail=1; echo "couldn't get a small subset" >&2; }
+# Ensure shuf -n0 doesn't read any input or open specified files
+touch unreadable || framework_failure_
+chmod 0 unreadable || framework_failure_
+shuf -n0 unreadable || fail=1
+shuf -n1 unreadable && fail=1
+
Exit $fail