-
Notifications
You must be signed in to change notification settings - Fork 1
/
opam.sh
executable file
·61 lines (58 loc) · 1.44 KB
/
opam.sh
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
#!/bin/sh
#usage: opam config var prefix -> return $PREFIX
#usage: opam config var lib -> return $PREFIX/lib
#usage: opam config subst <filename> -> replace %{jobs}% with 1 in <filename>.in, output to <filename>
#usage: opam var prefix -> return $PREFIX
#usage: opam var lib -> return $PREFIX/lib
#usage: opam subst (do nothing)
#usage: opam --version [] -> return 2.1.2
#usage: opam monorepo -> execute opam-monorepo
if [ "$1" = "--version" ]; then
echo "2.1.2";
exit 0;
elif [ "$1" = "monorepo" ]; then
for arg do
shift
[ "$arg" = "monorepo" ] && continue
set -- "$@" "$arg"
done
exec opam-monorepo $@
elif [ $# = 3 ]; then
if [ "$1" = "config" ]; then
if [ "$2" = "var" ]; then
if [ "$3" = "prefix" ]; then
echo "$PREFIX"
elif [ "$3" = "lib" ]; then
echo "$PREFIX/lib"
else
exit 1
fi
elif [ "$2" = "subst" ]; then
sed "s/%{jobs}%/1/g" $3.in > $3
else
exit 1
fi
else
exit 1
fi
elif [ $# = 2 ]; then
if [ "$1" = "var" ]; then
if [ "$2" = "prefix" ]; then
echo "$PREFIX"
elif [ "$2" = "lib" ]; then
echo "$PREFIX/lib"
else
exit 1
fi
else
exit 1
fi
elif [ $# = 1 ]; then
if [ "$1" = "subst" ]; then
exit 0
else
exit 1
fi
else
exit 1
fi