This repository was archived by the owner on Mar 23, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutil
More file actions
executable file
·99 lines (78 loc) · 1.89 KB
/
Copy pathutil
File metadata and controls
executable file
·99 lines (78 loc) · 1.89 KB
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
#!/bin/bash
function report() {
status="$?"
if [ -n "${subcmd+x}" ]; then
echo "$(red "OPERATION $subcmd FAILED")"
if [[ -e "$SCRIPTS/$subcmd" && "$status" == 1 ]]; then
$SCRIPTS/help $subcmd
fi
else
echo "$(red "COMMAND $BASH_COMMAND FAILED")"
fi
exit 1
}
set -eEuo pipefail
# set function to call if anything fails
trap report ERR
source "$PWD/files/base/scripts.conf"
# SCRIPT ENTRY POINT
if [ "$#" -lt 1 ]; then
error "no command given"
echo
$SCRIPTS/help
exit 1
fi
if [ "$1" != conf ]; then
if [ ! -e "$UTIL_CONFIG" ]; then
error "project is not configured"
echo
$SCRIPTS/help conf
exit 1
else
source $UTIL_CONFIG
if [ "$configured" != true ]; then
error "project is not configured"
echo
$SCRIPTS/help conf
exit 1
fi
fi
fi
args="${@:1}"
subcmd=$1
IFS="+"
for i in $args; do
# delete spaces at the start and at the end
i="${i#"${i%%[![:space:]]*}"}" # remove leading
i="${i%"${i##*[![:space:]]}"}" # remove trailing
IFS=" "
subcmd="${i%% *}" # first word
if [ "$(echo "$i" | wc -w)" -gt 1 ]; then
# has parameters
cmd_args="${i#* }"
if [ -e "$SCRIPTS/$subcmd" ]; then
$SCRIPTS/$subcmd $cmd_args
else
error "subcommand '$subcmd' does not exist"
$SCRIPTS/help
exit 1
fi
if [ "$subcmd" == build ]; then
$SCRIPTS/mkiso
fi
else
# no parameters
if [ -e "$SCRIPTS/$subcmd" ]; then
$SCRIPTS/$subcmd
else
error "subcommand '$subcmd' does not exist"
$SCRIPTS/help
exit 1
fi
if [ "$subcmd" == build ]; then
$SCRIPTS/mkiso
fi
fi
IFS="+"
done
exit