-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutils.sh
More file actions
executable file
·43 lines (37 loc) · 800 Bytes
/
utils.sh
File metadata and controls
executable file
·43 lines (37 loc) · 800 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
40
41
42
#!/bin/sh
set -e
yellow() {
msg="$@"
if [ -t 1 ]; then
printf "\033[1;33;49m%s\033[m\n" "$msg"
else
echo "$msg"
fi
}
say() {
msg="$@"
if [ -t 1 ]; then
printf "\033[1;34;49m%s\033[m\n" "$msg"
else
echo "$msg"
fi
}
complain() {
msg="$@"
if [ -t 1 ]; then
printf "\033[1;31;49m%s\033[m\n" "$msg"
else
echo "$msg"
fi
}
run() {
say "\$ $@"
local rc=0
"$@" || rc=$?
if [ $rc -ne 0 ]; then
complain "[E]: The command \"$@\" failed with status code $rc, terminating..."
yellow "[I]: Is your graphic card enabled? If you are on optimus system remember to activate the graphics using: optirun ./run [command]"
complain "[E]: If you have no idea of what went wrong, please feel free to ask for help in interscity.org"
exit 1
fi
}