-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathassert_dir
More file actions
executable file
·39 lines (33 loc) · 802 Bytes
/
assert_dir
File metadata and controls
executable file
·39 lines (33 loc) · 802 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#!/bin/bash
# by Stefan Ruedisuehli, 2015-08-25
FILE_CHECK=true
USAGE="Usage: $(basename ${0}) <DIR(S)>
Assert the existance of one or more directories."
main()
{
# Eval inargs
local narg_min=1
[ $# -lt ${narg_min} ] && { echo "${USAGE}" >&2; return 1; }
# Check directories
local stat=0
for dir in "${@}"
do
if [ ! -d "${dir}" ]
then
echo -n "error: directory not found: '${dir}'" >&2
if ${FILE_CHECK}
then
if [[ -f "${dir}" ]]
then
echo -n " (is a file)" >&2
else
echo -n " (is not a file, either)" >&2
fi
fi
echo
stat=1
fi
done
return ${stat}
}
main "${@}"