*** empty log message ***
[coreutils.git] / tests / chgrp / posix-H
blob1652e595b23f167705ee478fd8ac46143673f8a1
1 #!/bin/sh
2 # Test POSIX-mandated -H option.
4 if test "$VERBOSE" = yes; then
5 set -x
6 chgrp --version
7 fi
9 . $srcdir/../group-names
10 set _ $groups; shift
11 g1=$1
12 g2=$2
14 pwd=`pwd`
15 t0=`echo "$0"|sed 's,.*/,,'`.tmp; tmp=$t0/$$
16 trap 'status=$?; cd $pwd; chmod -R u+rwx $t0; rm -rf $t0 && exit $status' 0
17 trap '(exit $?); exit $?' 1 2 13 15
19 framework_failure=0
20 mkdir -p $tmp || framework_failure=1
21 cd $tmp || framework_failure=1
23 mkdir 1 2 3 || framework_failure=1
24 touch 1/1F 2/2F 3/3F || framework_failure=1
25 ln -s 1 1s || framework_failure=1
26 ln -s ../3 2/2s || framework_failure=1
27 chgrp -R $g1 1 2 3 || framework_failure=1
29 if test $framework_failure = 1; then
30 echo "$0: failure in testing framework" 1>&2
31 (exit 1); exit 1
34 fail=0
36 chgrp -HR $g2 1s 2 || fail=1
38 # These must have group $g2.
39 # =========================
40 changed='
42 1/1F
44 2/2s
45 2/2F
47 for i in $changed; do
48 # Filter out symlinks (entries that end in `s'), since it's not
49 # possible to change their group/owner information on some systems.
50 case $i in *s) continue;; esac
51 set _ `ls -dg $i`; shift
52 group=$3
53 test $group = $g2 || fail=1
54 done
56 # These must have group $g1.
57 # =========================
58 not_changed='
60 3/3F
63 for i in $not_changed; do
64 # Filter out symlinks (entries that end in `s'), since it's not
65 # possible to change their group/owner information on some systems.
66 case $i in *s) continue;; esac
67 set _ `ls -dg $i`; shift
68 group=$3
69 test $group = $g1 || fail=1
70 done
72 (exit $fail); exit $fail