summaryrefslogtreecommitdiff
path: root/tests/misc/stat-hyphen
diff options
context:
space:
mode:
authorJim Meyering <meyering@redhat.com>2009-09-15 23:07:18 +0200
committerJim Meyering <meyering@redhat.com>2009-09-29 16:04:12 +0200
commita033e28737c1f6320bfc56b484253b61051bad85 (patch)
tree8f663e656092685e09aa5f655ca97b43345ced46 /tests/misc/stat-hyphen
parentb7aaa0da8b47f4f373d3e0876bd540986278c6e2 (diff)
downloadcoreutils-a033e28737c1f6320bfc56b484253b61051bad85.tar.xz
stat: interpret "-" as standard input
* src/stat.c (do_stat): Interpret a command line argument of "-" to mean "standard input", like many other tools do. (do_statfs): Fail upon any attempt to use "-". * NEWS (Changes in behavior): Mention it. * tests/misc/stat-hyphen: New test, to exercise the above. * tests/Makefile.am (TESTS): Add misc/stat-hyphen.
Diffstat (limited to 'tests/misc/stat-hyphen')
-rwxr-xr-xtests/misc/stat-hyphen35
1 files changed, 35 insertions, 0 deletions
diff --git a/tests/misc/stat-hyphen b/tests/misc/stat-hyphen
new file mode 100755
index 000000000..f0757fe39
--- /dev/null
+++ b/tests/misc/stat-hyphen
@@ -0,0 +1,35 @@
+#!/bin/sh
+# demonstrate that stat - works and stat -f - does not.
+
+# Copyright (C) 2009 Free Software Foundation, Inc.
+
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+if test "$VERBOSE" = yes; then
+ set -x
+ stat --version
+fi
+
+. $srcdir/test-lib.sh
+
+printf -- '-\n' > exp || framework_failure
+touch f || framework_failure
+
+fail=0
+stat --format=%n - < f > out || fail=1
+stat -f - < f && fail=1
+
+compare out exp || fail=1
+
+Exit $fail