7d2d3de8838c7f9523891ab9f5bd9704a380a6a1
[platform/upstream/coreutils.git] / tests / misc / pathchk1
1 #!/bin/sh
2 # pathchk tests
3
4 if test "$VERBOSE" = yes; then
5   set -x
6   pathchk --version
7 fi
8
9 PRIV_CHECK_ARG=require-non-root . $srcdir/../priv-check
10
11 pwd=`pwd`
12 t0=`echo "$0"|sed 's,.*/,,'`.tmp; tmp=$t0/$$
13 trap 'status=$?; cd $pwd; rm -rf $t0 && exit $status' 0
14 trap '(exit $?); exit' 1 2 13 15
15
16 framework_failure=0
17 mkdir -p $tmp || framework_failure=1
18 cd $tmp || framework_failure=1
19 touch file || framework_failure=1
20
21 if test $framework_failure = 1; then
22   echo "$0: failure in testing framework" 1>&2
23   (exit 1); exit 1
24 fi
25
26 fail=0
27
28 # This should exit nonzero.  Before 2.0.13, it gave a diagnostic,
29 # but exited successfully.
30 pathchk file/x > /dev/null 2>&1 && fail=1
31
32 # This should exit nonzero.  Through 5.3.0 it exited with status zero.
33 pathchk -p '' > /dev/null 2>&1 && fail=1
34
35 # This tests the new -P option.
36 pathchk -P '' > /dev/null 2>&1 && fail=1
37 pathchk -P -- - > /dev/null 2>&1 && fail=1
38 pathchk -p -P x/- > /dev/null 2>&1 && fail=1
39
40 (exit $fail); exit $fail