File tree Expand file tree Collapse file tree 1 file changed +30
-3
lines changed Expand file tree Collapse file tree 1 file changed +30
-3
lines changed Original file line number Diff line number Diff line change 66# halt when referencing any unbound variable
77set -u
88
9+
10+ out () { printf %s\\ n " $* " ; }
11+ err () { >&2 printf %s\\ n " $* " ; }
12+ die () { >&2 printf %s\\ n " $* " ; exit 1 ; }
13+
914display_help () {
1015 cat << EOM
1116Usage: install.sh [OPTIONS]
@@ -18,6 +23,28 @@ Options:
1823EOM
1924}
2025
26+ install () {
27+ if [[ ! " $( force_install? ) " ]] && [[ -e " $( dst_file) " ]]; then
28+ err " file already exists: " " $( dst_file) "
29+ fi
30+
31+ local src_file=" $( dirname " ${0} " ) " /num
32+
33+ if ! cp " ${src_file} " " $( dst_file) " ; then
34+ err " Unable to copy '${src_file} ' to '$( dst_file) '"
35+ fi
36+ }
37+
38+ dst_file () {
39+ local dst_dir=" ${NUM_INSTALL_DIR:-/ usr/ local/ bin} "
40+ mkdir -p " ${dst_dir} "
41+ out " ${NUM_INSTALL_DIR:-/ usr/ local/ bin} " /num
42+ }
43+
44+ force_install? () {
45+ echo " ${NUM_FORCE_INSTALL:- " " } "
46+ }
47+
2148parse_args () {
2249 if [[ $@ ]]; then
2350 case " ${1} " in
@@ -35,8 +62,7 @@ parse_args () {
3562 exit 0
3663 ;;
3764 * )
38- echo " invalid option: " ${1} >&2
39- exit 1
65+ die " invalid option: " " ${1} "
4066 ;;
4167 esac
4268
@@ -47,4 +73,5 @@ parse_args () {
4773# parse command line options
4874parse_args $@
4975
50- # TODO: implement installer
76+ # install num
77+ install
You can’t perform that action at this time.
0 commit comments