-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathentrypoint.sh
More file actions
executable file
·46 lines (38 loc) · 953 Bytes
/
entrypoint.sh
File metadata and controls
executable file
·46 lines (38 loc) · 953 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
43
44
45
46
#!/usr/bin/env bash
__curl_http_error() {
local content_file
content_file=${1:?Please provide the retrieved content by curl}
local status_code
status_code=${2:?Please provide an HTTP status code}
[[ $(cut -f1 -d: "$content_file") == "$status_code" ]]
}
__download_code() {
curl --silent "$first_param" -o code.cpp
if __curl_http_error code.cpp 404; then
echo "Code could not be downloaded" >&2
exit 1
fi
}
__is_url() {
local param
param=${1:?Please provide a parameter (url|command) to check}
[[ $param =~ ^http ]]
}
__is_file() {
local param
param=${1:?Please provide a parameter (url|command) to check}
[ -f "$param" ]
}
first_param=${1:?Please provide a parameter (url|file|command)}
if __is_url "$first_param"; then
__download_code
set - code.cpp
elif __is_file "$first_param"; then
:
else
exec "$@"
fi
# shellcheck disable=SC1090
source ~/.bashrc
snip g++ -Wall --std=c++17 "$@" &&
tst ./a.out