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