global: convert indentation-TABs to spaces
[coreutils.git] / tests / chmod / usage
blob1f1894427db1a9c6bcf559a90d3b6c2095a0908a
1 #!/bin/sh
2 # Verify that chmod works correctly with odd option combinations.
4 # Copyright (C) 2004-2009 Free Software Foundation, Inc.
6 # This program is free software: you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation, either version 3 of the License, or
9 # (at your option) any later version.
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License
17 # along with this program. If not, see <http://www.gnu.org/licenses/>.
19 if test "$VERBOSE" = yes; then
20 set -x
21 chmod --version
24 . $srcdir/test-lib.sh
26 fail=0
28 # Each line in this list is a set of arguments, followed by :,
29 # followed by the set of files it will attempt to chmod,
30 # or empty if the usage is erroneous.
31 # Many of these test cases are due to Glenn Fowler.
32 # These test cases assume GNU behavior for "options" like -w.
33 cases='
34 -- :
35 -- -- :
36 -- -- -- f : -- f
37 -- -- -w f : -w f
38 -- -- f : f
39 -- -w :
40 -- -w -- f : -- f
41 -- -w -w f : -w f
42 -- -w f : f
43 -- f :
44 -w :
45 -w -- :
46 -w -- -- f : -- f
47 -w -- -w f : -w f
48 -w -- f : f
49 -w -w :
50 -w -w -- f : f
51 -w -w -w f : f
52 -w -w f : f
53 -w f : f
54 f :
55 f -- :
56 f -w : f
57 f f :
58 u+gr f :
59 ug,+x f :
62 all_files=`echo "$cases" | sed 's/.*://'|sort -u`
64 old_IFS=$IFS
65 IFS='
67 for case in $cases; do
68 IFS=$old_IFS
69 args=`expr "$case" : ' *\(.*[^ ]\) *:'`
70 files=`expr "$case" : '.*: *\(.*\)'`
72 case $files in
73 '')
74 touch -- $all_files || framework_failure
75 chmod $args 2>/dev/null && fail=1
77 ?*)
78 touch -- $files || framework_failure
79 chmod $args || fail=1
80 for file in $files; do
81 # Test for misparsing args by creating all $files but $file.
82 # chmod has a bug if it succeeds even though $file is absent.
83 rm -f -- $all_files && touch -- $files && rm -- $file \
84 || framework_failure
85 chmod $args 2>/dev/null && fail=1
86 done
88 esac
89 done
91 Exit $fail