*** empty log message ***
[coreutils.git] / tests / chown / separator
blobfec1b582774687bc74a26757ce989e56b5f83ed5
1 #!/bin/sh
2 # Make sure "chown USER:GROUP FILE" works, and similar tests with separators.
4 if test "$VERBOSE" = yes; then
5 set -x
6 chown --version
7 fi
9 pwd=`pwd`
10 t0=`echo "$0" |sed 's,.*/,,'`.tmp; tmp=$t0/$$
11 trap 'status=$?; cd $pwd; chmod -R u+rwx $t0; rm -rf $t0 && exit $status' 0
12 trap 'status=$?; (exit $status); exit $status' 1 2 13 15
14 framework_failure=0
16 mkdir -p $tmp || framework_failure=1
17 cd $tmp || framework_failure=1
19 id_u=`id -u` || framework_failure=1
20 test -n "$id_u" || framework_failure=1
22 id_un=`id -un` || framework_failure=1
23 test -n "$id_un" || framework_failure=1
25 id_g=`id -g` || framework_failure=1
26 test -n "$id_g" || framework_failure=1
28 id_gn=`id -gn` || framework_failure=1
29 test -n "$id_gn" || framework_failure=1
31 if test $framework_failure = 1; then
32 echo "$0: failure in testing framework" 1>&2
33 (exit 1); exit 1
36 fail=0
38 chown '' . || fail=1
40 for u in $id_u $id_un ''; do
41 for g in $id_g $id_gn ''; do
42 case $u$g in
43 *.*) seps=':' ;;
44 *) seps=': .' ;;
45 esac
46 for sep in $seps; do
47 case $u$sep$g in
48 [0-9]*$sep) chown "$u$sep$g" . 2> /dev/null && fail=1 ;;
49 *) chown "$u$sep$g" . || fail=1 ;;
50 esac
51 done
52 done
53 done
55 (exit $fail); exit $fail