-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.sh
More file actions
44 lines (42 loc) · 1.13 KB
/
main.sh
File metadata and controls
44 lines (42 loc) · 1.13 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
#!/usr/bin/env bash
function fb_verifyArgs() {
local errorMessage=$1
numberOfArgsExpected=$2
local args=${@:3}
numberOfArgsProvided=0
if [[ ${args[@]} == "" ]]; then
echo "No arguments provided to verify"
return
fi
for arg in ${args[@]};
do
numberOfArgsProvided=$((numberOfArgsProvided+1))
if [[ $arg == "" ]]; then
echo $errorMessage
echo "Argument #$numberOfArgsProvided was not provided."
return
fi
done
if [[ ! "$numberOfArgsProvided" == "$numberOfArgsExpected" ]]; then
echo "Incorrect number of arguments provided"
return
fi
return
}
function fb_remoteSource() {
local verified=$(fb_verifyArgs "fb_remoteSource requires an argument to source" 1 $@)
if [[ $verified == "" ]]; then
if [ -s $1 ]; then
echo "source local $1"
source $1
else
echo "source remote $1"
tmpfile=$(mktemp /tmp/abc-script.XXXXXX)
curl $1 -o $tmpfile
source $tmpfile
rm $tmpfile
fi
else
echo $verified
fi
}