1#!/bin/bash 2 3[ -f testing.sh ] && . testing.sh 4 5#testing "name" "command" "result" "infile" "stdin" 6 7testing "mkdir" "mkdir one && [ -d one ] && echo yes" "yes\n" "" "" 8rmdir one 9 10touch existing 11testing "mkdir existing" \ 12 "mkdir existing 2> /dev/null || [ -f existing ] && echo yes" "yes\n" "" "" 13rm existing 14 15testing "mkdir one two" \ 16 "mkdir one two && [ -d one ] && [ -d two ] && echo yes" "yes\n" "" "" 17rmdir one two 18 19testing "mkdir missing/one" \ 20 "mkdir missing/one 2> /dev/null || [ ! -d missing ] && echo yes" "yes\n" "" "" 21 22testing "mkdir -p" \ 23 "mkdir -p one/two/three && [ -d one/two/three ] && echo yes" "yes\n" "" "" 24rm -rf one 25 26mkdir existing 27testing "mkdir -p existing" "mkdir -p existing && echo yes" "yes\n" "" "" 28rmdir existing 29 30umask 123 31testing "mkdir (default permissions)" \ 32 "mkdir one && stat -c %a one" "654\n" "" "" 33rmdir one 34 35testing "mkdir -m 124" \ 36 "mkdir -m 124 one && stat -c %a one" "124\n" "" "" 37rmdir one 38 39umask 000 40testing "mkdir -p -m 653" \ 41 "mkdir -p -m 653 one/two && stat -c %a one && stat -c %a one/two" \ 42 "777\n653\n" "" "" 43rm -rf one 44 45testing "mkdir -p one/two/ (trailing slash)" \ 46 "mkdir -p one/two/ && [ -d one/two ] && echo yes" "yes\n" "" "" 47rm -rf one 48 49umask 022 50testing "mkdir -p -m 777 (022 umask)" \ 51 "mkdir -p -m 777 one/two && stat -c %a one && stat -c %a one/two" \ 52 "755\n777\n" "" "" 53rm -rf one 54 55umask 377 56testing "mkdir -p -m 777 (377 umask)" \ 57 "mkdir -p -m 777 one/two && stat -c %a one && stat -c %a one/two" \ 58 "700\n777\n" "" "" 59umask 002 60rm -rf one 61 62testing "mkdir -vp" "mkdir -vp walrus 2>&1" \ 63 "mkdir: created directory 'walrus'\n" "" "" 64 65testing "mkdir -vp exists" "mkdir -vp walrus 2>&1" \ 66 "" "" "" 67rm -rf walrus 68 69touch two 70testing "mkdir continue after fail" \ 71 "mkdir -m 777 one two three 2>/dev/null || stat -c %a three" \ 72 "777\n" "" "" 73rm -rf one two three 74