-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathlist-scheme-systems.bash
executable file
·93 lines (84 loc) · 2.26 KB
/
list-scheme-systems.bash
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
#!/usr/bin/env bash
# This program and the accompanying materials are made available under the
# terms of the MIT license (X11 license) which accompanies this distribution.
# author: C. Bürger
set -e
set -o pipefail
shopt -s inherit_errexit
script_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
results=() # Collect results and only print them if ALL arguments are valid.
############################################################################################################## Process arguments:
if [ $# -eq 0 ]
then
"$script_dir/list-scheme-systems.bash" -h
exit $?
fi
while getopts kis:h opt
do
case $opt in
k)
for s in chez guile racket larceny sagittarius ypsilon ironscheme
do
results+=( "$s" )
done
;;
i)
found=""
for s in chez guile racket larceny sagittarius ypsilon
do
if command -v "$s" > /dev/null
then
results+=( "$s" )
found="true"
fi
done
if command -v IronScheme.Console-v4.exe > /dev/null
then
results+=( "ironscheme" )
found="true"
fi
if [ "$found" = "" ]
then
echo " !!! ERROR: No supported Scheme system found !!!" >&2
exit 64
fi
;;
s)
found=""
mapfile -t installed_systems < <( "$script_dir/list-scheme-systems.bash" -i || kill -13 $$ )
for s in "${installed_systems[@]}"
do
if [ "$OPTARG" == "$s" ]
then
found="true"
break
fi
done
if [ "$found" = "" ]
then
echo " !!! ERROR: [$OPTARG] Scheme system selected via -s parameter unavailable !!!" >&2
exit 64
fi
;;
h|?)
echo "Usage: -k List all Scheme systems officially supported by RACR (multi-flag)." >&2
echo " -i List all installed and officially supported Scheme systems (multi-flag)." >&2
echo " Abort with an error if no supported system is installed." >&2
echo " -s Ensure a certain system is installed and supported (multi-parameter)." >&2
echo " Abort with an error if not." >&2
exit 64
;;
esac
done
shift $(( OPTIND - 1 ))
if [ ! $# -eq 0 ]
then
echo " !!! ERROR: Unknown [$*] command line arguments !!!" >&2
exit 64
fi
################################################################################################################## Print results:
for r in "${results[@]}"
do
echo "$r"
done
exit 0