.
[coreutils.git] / tests / mkdir / parents
blobcf0e97d4ab5491880b85f35b347aeb0741035ffe
1 #!/bin/sh
2 # make sure mkdir's -p options works properly
4 if test "$VERBOSE" = yes; then
5 set -x
6 mkdir --version
7 fi
9 pwd=`pwd`
10 tmp=parents-$$
11 trap 'status=$?; cd $pwd; rm -rf $tmp && exit $status' 0
12 trap '(exit $?); exit' 1 2 13 15
14 framework_failure=0
16 # Record absolute path of srcdir.
17 cd $srcdir || framework_failure=1
18 abs_srcdir=`pwd`
20 cd $pwd || framework_failure=1
21 mkdir $tmp || framework_failure=1
22 cd $tmp || framework_failure=1
23 mkdir -m 700 e-dir || framework_failure=1
25 if test $framework_failure = 1; then
26 echo 'failure in testing framework'
27 (exit 1); exit
30 . $abs_srcdir/../setgid-check
32 fail=0
34 # Make sure `mkdir -p existing-dir' succeeds
35 # and that `mkdir existing-dir' fails.
36 mkdir -p e-dir || fail=1
37 mkdir e-dir > /dev/null 2>&1 && fail=1
39 # Create an existing directory.
40 umask 077
41 mode_str=drwxr-x-wx
42 mode_arg=`$abs_srcdir/../rwx-to-mode $mode_str`
43 mkdir -m $mode_arg a || fail=1
45 # this `mkdir -p ...' shouldn't change perms of existing dir `a'.
46 d_mode_str=drwx-w--wx
47 d_mode_arg=`$abs_srcdir/../rwx-to-mode $d_mode_str`
48 mkdir -p -m $d_mode_arg a/b/c/d
50 # Make sure the permissions of `a' haven't been changed.
51 p=`ls -ld a|sed 's/ .*//'`; case $p in $mode_str);; *) fail=1;; esac
52 # `b's and `c's should reflect the umask
53 p=`ls -ld a/b|sed 's/ .*//'`; case $p in drwx------);; *) fail=1;; esac
54 p=`ls -ld a/b/c|sed 's/ .*//'`; case $p in drwx------);; *) fail=1;; esac
56 # `d's perms are determined by the -m argument.
57 p=`ls -ld a/b/c/d|sed 's/ .*//'`; case $p in $d_mode_str);; *) fail=1;; esac
59 (exit $fail); exit