1 #!/bin/bash 2 3 [ -f testing.sh ] && . testing.sh 4 5 #testing "name" "command" "result" "infile" "stdin" 6 7 mkdir one 8 testing "rmdir" "rmdir one && [ ! -d one ] && echo yes" "yes\n" "" "" 9 10 touch walrus 11 testing "rmdir file" \ 12 "rmdir walrus 2> /dev/null || [ -f walrus ] && echo yes" "yes\n" "" "" 13 14 mkdir one two 15 testing "rmdir one two" \ 16 "rmdir one two 2> /dev/null && [ ! -d one ] && [ ! -d two ] && echo yes" \ 17 "yes\n" "" "" 18 19 mkdir one two three 20 testing "rmdir one missing two file three" \ 21 "rmdir one missing two walrus three 2> /dev/null || [ ! -d three ] && echo yes" \ 22 "yes\n" "" "" 23 rm walrus 24 25 mkdir one 26 chmod 000 one 27 testing "rmdir mode 000" "rmdir one && [ ! -d one ] && echo yes" "yes\n" "" "" 28 29 mkdir temp 30 touch temp/thing 31 testing "rmdir non-empty" \ 32 "rmdir temp 2>/dev/null || [ -d temp ] && echo yes" "yes\n" "" "" 33 testing "rmdir -p dir/file" \ 34 "rmdir -p temp/thing 2>/dev/null || [ -f temp/thing ] && echo yes" \ 35 "yes\n" "" "" 36 37 mkdir -p temp/one/two/three 38 testing "rmdir -p part of path" \ 39 "rmdir -p temp/one/two/three 2>/dev/null || [ -d temp ] && [ ! -e temp/one ] && echo yes" \ 40 "yes\n" "" "" 41 rm -rf temp 42 43 44 mkdir -p one/two/three 45 testing "rmdir -p one/two/three" \ 46 "rmdir -p one/two/three && [ ! -e one ] && echo yes" "yes\n" "" "" 47 48 mkdir -p one/two/three 49 testing "rmdir -p one/two/three/" \ 50 "rmdir -p one/two/three/ && [ ! -e one ] && echo yes" "yes\n" "" "" 51 52 #mkdir -p one/two/three 53 #chmod 000 one/two/three one/two one 54 #testing "rmdir -p one/two/three" \ 55 # "rmdir -p one/two/three && [ ! -e one ] && echo yes" "yes\n" "" "" 56