ff5d16e2cc75606d7122344133807a4bfdd0d2bb
[platform/upstream/coreutils.git] / tests / chmod / c-option
1 #!/bin/sh
2 # Verify that chmod's --changes (-c) option works.
3
4 if test "$VERBOSE" = yes; then
5   set -x
6   chmod --version
7 fi
8
9 . $srcdir/../lang-default
10
11 pwd=`pwd`
12 tmp=c-option.$$
13 trap 'status=$?; cd $pwd; rm -rf $tmp && exit $status' 0
14 trap '(exit $?); exit' 1 2 13 15
15
16 framework_failure=0
17
18 # Record absolute path of srcdir.
19 cd $srcdir || framework_failure=1
20 abs_srcdir=`pwd`
21
22 cd $pwd || framework_failure=1
23 mkdir $tmp || framework_failure=1
24 cd $tmp || framework_failure=1
25
26 umask 0
27 file=f
28 touch $file || framework_failure=1
29 chmod 444 $file || framework_failure=1
30
31 if test $framework_failure = 1; then
32   echo 'failure in testing framework'
33   (exit 1); exit 1
34 fi
35
36 . $abs_srcdir/../setgid-check
37
38 fail=0
39
40 chmod u=rwx $file || fail=1
41 chmod -c g=rwx $file > out || fail=1
42 chmod -c g=rwx $file > empty || fail=1
43
44 test -s empty && fail=1
45 case "`cat out`" in
46   "mode of \`f' changed to 0774 "?rwxrwxr--?) ;;
47   *) fail=1 ;;
48 esac
49
50 (exit $fail); exit $fail