-
-
Notifications
You must be signed in to change notification settings - Fork 17
/
bashmatic-install
executable file
·664 lines (578 loc) · 22.9 KB
/
bashmatic-install
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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
#!/bin/bash
# vim: ft=bash
#
# The purpose of this script is to bootstrap Bashmatic on a
# new system. We are supporting OS-X and linux, although on
# OS-X we do a lot more initialization to ensure Bashmatic
# can properly function.
#
# Bootstrap script is required to run at least once on a new
# system, which happens automatically if you install it via
#
# bash -c "$(curl -fsSL https://bashmatic.re1.re); bashmatic-install -v"
#
set +e
# Configuration
export HOME=${HOME:-"/"}
declare -a CHOWN_DIRS
declare -a BREW_PACKAGES
export CHOWN_DIRS=(/usr/local/Cellar /usr/local/Homebrew /usr/local/Caskroom /opt/homebrew)
export BREW_PACKAGES=(coreutils gnu-sed)
# Constants
export clr='\e[0m' # Text Reset
export bldblk='\e[1;30m' # Black - Bold
export bldred='\e[1;31m' # Red
export bldgrn='\e[1;32m' # Green
export bldylw='\e[1;33m' # Yellow
export bldblu='\e[1;34m' # Blue
export bldpur='\e[1;35m' # Purple
export bldcyn='\e[1;36m' # Cyan
export bldwht='\e[1;37m' # White
export txtblk='\e[0;30m' # Black - Regular
export txtred='\e[0;31m' # Red
export txtgrn='\e[0;32m' # Green
export txtylw='\e[0;33m' # Yellow
export txtblu='\e[0;34m' # Blue
export txtpur='\e[0;35m' # Purple
export txtcyn='\e[0;36m' # Cyan
export txtwht='\e[0;37m' # White
# Output Helpers
function .ts() {
date '+%Y/%m/%d %I:%M:%S%p'
}
function .puts() {
for str in "$@"; do
printf "${clr}${bldwht}${bakblu} INFORMATION ➜ ${clr} ${txtblu}${str}${clr}\n"
done
}
function .err() {
for str in "$@"; do
printf "${clr}${bldwht}${bakred} ERROR ➜ ${clr} ${bldred}${str}${clr}\n"
done
}
function .wrn() {
for str in "$@"; do
printf "${clr}${txtblk}${bakylw} WARNING ➜ ${clr} ${bldylw}${str}${clr}\n"
done
}
#——————————————————————————————————————————————————————————————————————————————————————
# Sudo Helpers
#——————————————————————————————————————————————————————————————————————————————————————
function .sudo-ask() {
sudo -n true 2>/dev/null || {
.puts "Please enter your SUDO password: "
sudo -v
}
}
function .sudo-enable() {
sudo mkdir -p "${bootstrap__sudoers_dir}"
[[ -s ${bootstrap__sudoers_dir}/${USER} ]] || {
echo "${USER}" 'ALL=(ALL) NOPASSWD: ALL' |
sudo tee -a "${bootstrap__sudoers_dir}/${USER}" >/dev/null
trap "sudo-disable" EXIT
}
}
function .sudo-disable() {
sudo rm -f "${bootstrap__sudoers_dir}/${USER}"
}
#——————————————————————————————————————————————————————————————————————————————————————
# BASH Upgrade Functionality (OS-X/linux)
#——————————————————————————————————————————————————————————————————————————————————————
function .install.bash-major-version() {
local bash="${1:-"bash"}"
${bash} --version | head -1 | sed 's/[^0-9.]//g; s/\..*$//g'
}
function .install.bash-latest-installed-version() {
local version=$(bash-major-version "$(command -v bash)")
if [[ -x /usr/local/bin/bash ]]; then
local v=$(bash-major-version /usr/local/bin/bash)
[[ ${v} -gt ${version} ]] && version="${v}"
fi
echo "${version}"
}
function .install.bash-install-required() {
[[ $(bash-latest-installed-version) -lt 4 ]]
}
# Bash Installer Helpers
function .install.bash-install() {
.puts "Installing BASH v${bootstrap__bash_version} into ${bldylw}${bootstrap__bash_prefix}"
.puts "Please wait..."
.install.bash-from-sources "${bootstrap__bash_version}" "${bootstrap__bash_prefix}"
}
# Install BASH from sources
function .install.bash-from-sources() {
local version="$1"
local prefix="${2:-"/usr/local"}"
local bash_path="${prefix}/bin/bash"
if [[ -x ${bash_path} ]]; then
.err "BASH is already installed in ${bash_path}, version $(${bash_path} --version | head 1)"
return 1
fi
local bash_tar="bash-${version}.tar.gz"
local bash_url="http://ftp.gnu.org/gnu/bash/${bash_tar}"
local temp=/tmp/bash-sources
set -exo pipefail
rm -rf ${temp}
mkdir -p ${temp}
trap "rm -rf '${temp}'" EXIT
# shellcheck disable=SC2064
trap "cd ${PWD} || true" EXIT
cd "${temp}" || return 1
is-verbose &&.puts "Downloading BASH from ${bldylw}${bash_url}..."
curl -sO "${bash_url}"
tar xzf "${bash_tar}"
cd "bash-${version}"
is-verbose &&.puts "Configuring BASH in ${temp}, please wait..."
./configure --prefix="${prefix}" >/dev/null
is-verbose &&.puts "Building BASH, please wait..."
make -j 12 --silent
set +e
is-verbose &&.puts "Installing BASH into ${prefix}, please wait..."
(make --silent install || sudo make --silent install) 2>/dev/null
if [[ -x "${bash_path}" ]]; then
export PATH="${prefix}/bin:${PATH}"
grep -q "${bash_path}" /private/etc/shells || {
is-verbose &&.puts "Appending ${bash_path} to /etc/shells..."
echo "${bash_path}" | sudo tee -a /private/etc/shells >/dev/null
}
fi
is-quiet ||.puts " ✅ BASH version ${version} is ${bldgrn}installed in ${bldylw}${prefix}."
return 0
}
function .install.bash-install-if-needed() {
is-verbose &&.puts "Checking if I need to install modern BASH version..."
bash-install-required || return
.sudo-ask && .sudo-enable
bash-install
}
#——————————————————————————————————————————————————————————————————————————————————————
# Check for locally modiifed files
# Complain if bashmatic folder has locally modified files.
#——————————————————————————————————————————————————————————————————————————————————————
function .install.git-sync() {
is-verbose &&.puts "Checking if existing bashmatic folder is locally modified..."
((bootstrap__skip_git_check)) && return 0
cd "${BASHMATIC_HOME}" >/dev/null
[[ -d ".git" ]] || return
if [[ -n $(git status -s) ]]; then
.wrn "It appears you already installed Bashmatic into ${BASHMATIC_HOME}." \
"Normally we would pull the latest changes during this operation," \
"but we detected locally modified files under ${bldwht}${BASHMATIC_HOME}."
.puts "Please commit, stash or remove those files, and try again."
.puts "For your information, here are the modifications:"
echo
git status -s || true
echo
return 1
else
git branch --set-upstream-to=origin/main main
git checkout -q "${bootstrap__git_branch}" && git pull -q --rebase >/dev/null
fi
}
#——————————————————————————————————————————————————————————————————————————————————————
# LINUX
#——————————————————————————————————————————————————————————————————————————————————————
function .install.linux-requirements() {
for package in unzip git curl; do
command -v "${command}" >/dev/null || {
apt-get install "${command}" -yqq || sudo apt-get install "${command}" -yqq
}
done
}
#——————————————————————————————————————————————————————————————————————————————————————
# OS-X
#——————————————————————————————————————————————————————————————————————————————————————
function .install.osx-permissions() {
local -a dirs
for dir in "${CHOWN_DIRS[@]}"; do
is-verbose &&.puts "Checking (and possibly changing) permissions of ${bldylw}${dir}..."
[[ -d "${dir}" ]] || continue
[[ $(stat -f %u "${dir}") -eq $(id -u) ]] && continue
dirs+=( "${dir}" )
done
[[ ${#dirs[@]} -eq 0 ]] && return 0
.sudo-ask && .sudo-enable
for d in "${dirs[@]}"; do
set -x
sudo chown -R "${USER}" "${d}"
set +x
done
}
# Brew Installer Helpers
# Install Brew
function .install.brew-install() {
is-verbose &&.puts "Installing HomeBrew if not already there..."
command -v brew >/dev/null || {
.puts "Installing Homebrew, please wait..."
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
}
}
function .install.brew-deps() {
set +e
is-verbose &&.puts "Installing required brew packages..."
local brew_cache=/tmp/brew_cache.$$
trap "rm -f '${brew_cache}'" EXIT
brew list --formulae -1 >"${brew_cache}"
for package in "${BREW_PACKAGES[@]}"; do
is-verbose &&.puts "Checking/installing brew package ${bldylw}${package}..."
grep -q "${package}" "${brew_cache}" || brew install "${package}" 1>/dev/null 2>&1
done
}
# Uninstall Brew (just for completeness, we never actually use this)
function .install.brew-uninstall() {
echo y | /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/uninstall.sh)"
}
function .install.darwin-requirements-xcode() {
is-verbose && .puts "Verifying and installing XCode Dependencies..."
command -v git >/dev/null && return 0
local xcode_app="/Applications/Xcode.app"
local xcode_tools="${xcode_app}/Contents/Developer"
local cli_tools="/Library/Developer/CommandLineTools"
if [[ -d "${xcode_app}" && -d "${xcode_tools}" ]]; then
[[ $(xcode-select -p) == "${xcode_tools}" ]] || sudo xcode-select --switch "${xcode_tools}"
else
command -v xcodebuild >/dev/null && command -v xcode-select >/dev/null && {
xcode-select --install 2>&1 || {
.err "Error running xcode-select --install" "You may need to download and install XCode Command Line Tools Manually."
.puts "We'll open the URL where you can download the tools in 5 seconds."
.puts "You will need to login with your Apple ID."
sleep 1
.puts "When you are finished installing the tools, re-run Bashmatic Install script."
sleep 4
.puts "Opening Apple website..."
sleep 0.5
open "https://developer.apple.com/download/more/?=command%20line%20tools"
exit 1
}
}
[[ -d "${cli_tools}" && $(xcode-select -p) == "${cli_tools}" ]] || sudo xcode-select --switch ${cli_tools} 2>/dev/null
fi
is-verbose &&.puts "Accepting XCode license..."
bash -c 'command -v xcodebuild >/dev/null && sudo xcodebuild -license accept 2>&1 1>/dev/null; true ' >/dev/null
}
function .install.darwin-requirements() {
.install.darwin-requirements-xcode
.install.osx-permissions
.install.brew-install
.install.brew-deps
}
#——————————————————————————————————————————————————————————————————————————————————————
# Ensure OS-specific reqquirements are satisfied
#——————————————————————————————————————————————————————————————————————————————————————
function .install.os-requirements() {
case ${BASHMATIC_OS} in
darwin)
.install.darwin-requirements
;;
linux)
.install.linux-requirements
;;
*)
.err "Operating system ${BASHMATIC_OS} is not supported."
exit 1
;;
esac
}
#——————————————————————————————————————————————————————————————————————————————————————
# Main Body
#——————————————————————————————————————————————————————————————————————————————————————
unset BASHMATIC_DEBUG
export bootstrap__skip_git_check=0
export bootstrap__skip_install=0
export bootstrap__verbose=0
export bootstrap__quiet=0
export bootstrap__force=0
export bootstrap__print=0
export bootstrap__skip_on_login=0
export bootstrap__bashmatic_home=${HOME}/.bashmatic
export bootstrap__bash_version="5.1-rc2"
export bootstrap__bash_prefix="/usr/local"
export bootstrap__sudoers_dir="/private/etc/sudoers.d"
export bootstrap__git_method="https"
export bootstrap__git_branch="main"
export BASHMATIC_OS="$(uname -s | tr '[:upper:]' '[:lower:]')"
function is-debug() {
((BASHMASTIC_DEBUG))
}
function is-verbose() {
((bootstrap__verbose))
}
function is-quiet() {
((bootstrap__quiet))
}
function is-force() {
((bootstrap__force))
}
function .install.usage() {
printf "
${bldylw}USAGE:
${bldgrn}bin/bashmatic-install [ flags ]
${bldylw}DESCRIPTION:
${bldblu}Install Bashmatic, and on OSX also installs build tools, brew and latest bash
into /usr/local/bin/bash.
${bldylw}FLAGS:${clr}
-m, --git-method [git|https] The default is 'https' unless your username is 'kig'.
-b, --git-branch [branch|tag] Use a concrete branch or a tag when installing, defaults to
the 'main' branch.
-H, --bashmatic-home PATH Install bashmatic into PATH (default: ${bootstrap__bashmatic_home/${HOME}/\~})
-V, --bash-version VERSION Install BASH VERSION (default: ${bootstrap__bash_version})
-P, --bash-prefix PATH Install BASH into PATH (default: ${bootstrap__bash_prefix})
-l, --skip-on-login Do not install Bashmatic Hook into your dotfiles, which
it does by the default. If you skip it, you can always
change your mind later and add it to your shell dot files
by running the following on the command line:
You can always do so later with the following:
${bldgrn}$ ~/.bashmatic/bin/bashmatic load-at-login ${clr}
This above will install the Bashmatic hook into your shell
dotfile, eg ${txtcyn}~/.bash_profile.${clr} if you are on BASH,
or ${txtcyn}~/.zshrc${clr} if you are on ZSH..
-g, --skip-git Do not abort if the destination has local changes
-i, --skip-install Only install/verify prerequisites, skip install.
-p, --print-home Print the identied canonical folder.
-v, --verbose See additional output as bootstrap is running.
-f, --force Force a reinstall of any existing target.
-q, --quiet See only.error output.
-d, --debug Print the values of configuration variables for debugging.
-h, --help Show this help message.
${clr}\n\n"
}
function .install.parse-opts() {
# Parse additional flags
while :; do
case $1 in
-V | --bash-version)
shift
export bootstrap__bash_version=$1
shift
;;
-P | --bash-prefix)
shift
export bootstrap__bash_prefix="$1"
[[ -d ${bootstrap__bash_prefix} ]] && {
.err "Prefix PATH ${bootstrap__bash_prefix} does not exist."
exit 1
}
shift
;;
-H | --bashmatic-home)
shift
export bootstrap__bashmatic_home="$1"
[[ -z ${bootstrap__bashmatic_home} ]] && {
.err "-H requires a valid argument."
exit 1
}
shift
;;
-m | --git-method)
shift
export bootstrap__git_method="$1"
[[ ${bootstrap__git_method} == "https" || ${bootstrap__git_method} == "git" ]] || {
.err "Invalid usage of -m, expected either https or git."
exit 1
}
[[ ${bootstrap__git_method} == "https" ]] && export bootstrap__skip_git_check=1
shift
;;
-b | --git-branch)
shift
export bootstrap__git_branch="$1"
[[ -z ${bootstrap__git_branch} ]] && {
.err "-b flag requires either a tag or a branch name."
exit 1
}
shift
;;
-p | --print)
shift
export bootstrap__print=1
;;
-d | --debug)
shift
export DEBUG=1
export BASHMATIC_DEBUG=1
export BASHMATIC_PATH_DEBUG=1
;;
-v | --verbose)
shift
export bootstrap__verbose=1
export bootstrap__quiet=0
;;
-q | --quiet)
shift
export bootstrap__verbose=0
export bootstrap__quiet=1
;;
-g | --skip-git)
shift
export bootstrap__skip_git_check=1
;;
-i | --skip-install)
shift
export bootstrap__skip_install=1
;;
-l | --skip-on-login)
shift
export bootstrap__skip_on_login=1
;;
-f | --force)
shift
export bootstrap__force=1
;;
-h | -\? | --help)
shift
.install.usage
return 1
;;
--) # End of all options; anything after will be passed to the action function
shift
break
;;
-?*)
printf 'WARN: Unknown option (ignored): %s\n' "$1" >&2
exit 127
shift
;;
*)
[[ -z "$1" ]] && break
shift
;;
esac
done
if [[ "${bootstrap__git_method}" == "git" ]]; then
export BASHMATIC_URL="git@github.com:kigster/bashmatic"
elif [[ "${bootstrap__git_method}" == "https" ]]; then
export BASHMATIC_URL="https://github.com/kigster/bashmatic"
else
.err "Invalid git method, please set to either git or https."
exit 1
fi
}
function .install.download-and-install() {
export BASHMATIC_HOME="${bootstrap__bashmatic_home}"
local code=0
if [[ -d "${BASHMATIC_HOME}" && -f "${BASHMATIC_HOME}/init.sh" && ${bootstrap__force} -eq 0 ]]; then
.install.git-sync || return 1
else
((bootstrap__force)) && [[ ${PWD} != "${BASHMATIC_HOME}" && -d ${BASHMATIC_HOME} ]] && {
.wrn "Warning: removing existing ${BASHMATIC_HOME}..."
rm -rf "${BASHMATIC_HOME}"
}
local cmd="git clone --depth 1 --branch \"${bootstrap__git_branch}\" -q \"${BASHMATIC_URL}\" \"${BASHMATIC_HOME}\""
((bootstrap__verbose)) && eval "set -ex; ${cmd}; set +ex"
((bootstrap__verbose)) || eval "${cmd}" >/dev/null
code=$?
set +x
fi
if [[ ${code} -ne 0 ]]; then
.err "Bashmatic could not install or update correctly."
.err "Please run this manualy:\n\n\t${bldgrn}cd \$(dirname ${BASHMATIC_HOME} && git clone ${BASHMATIC_URL} ${BASHMATIC_HOME})\n\n"
return 1
else
export BASHMATIC_INIT="${BASHMATIC_HOME}/init.sh"
[[ -s "${BASHMATIC_INIT}" ]] || {
.err "Unexpected.error: ${BASHMATIC_INIT} was not found."
return 1
}
# shellcheck disable=SC1090
((bootstrap_debug)) && source "${BASHMATIC_HOME}/.envrc.debug"
source "${BASHMATIC_INIT}"
((bootstrap__skip_on_login)) || bashmatic.load-at-login
is-quiet || success "Your BashMatic has been successfully installed."
return 0
fi
}
function .install.run-not-source() {
.err "This script is meant to be run, not sourced in."
.puts "However, since you've already loaded it you can fun functions:"
}
function .install.current-shell() {
if [[ -z $(which grep) || -z $(which sed) || -z $(which cut) ]]; then
# something is seriosly screwy with the system's PATH.
# Perhaps we are in a Docker container.
export PATH="${PATH}:/bin:/usr/bin:/usr/local/bin:/sbin:/usr/sbin:/usr/local/sbin:/opt/local/bin:/opt/bin"
fi
[[ -z ${LC_CTYPE} ]] && export LC_CTYPE=C
[[ -z ${LANG} ]] && export LANG=C
[[ -n ${current_shell} ]] && /bin/ps -p $$ -o args | grep -q "${current_shell}" && {
printf -- '%s' "${current_shell/ /}" | tr -d ' '
return 0
}
(
# deterministicaly figure out our currently loaded shell.
local bash_process="$(/bin/ps -p $$ -o args | grep -v -E 'ARGS|COMMAND' | cut -d ' ' -f 1 | sed -E 's/-//g')"
current_shell="$(basename "${bash_process:-bash}")"
export current_shell
if [[ "${current_shell}" =~ zsh ]]; then
command -v zsh
elif [[ "${current_shell}" =~ bash ]]; then
command -v bash
else
.wrn "Detected an unsupported shell type: ${current_shell}" >&2
command -v "${current_shell}"
fi
) | tr -d ' '
}
function .install.canonical-source() {
current_shell=$(.install.current-shell)
if [[ "${current_shell}" =~ zsh ]]; then
printf "%s" "$0:A"
elif [[ "${current_shell}" =~ bash ]]; then
printf "%s" "${BASH_SOURCE[0]}"
else
printf "%s" "$0"
fi
}
function canonical-dir() {
local dir="$1"
[[ -d "${dir}" ]] || {
.err "Unable to determine canonical dir form source: ${dir}"
return 1
}
(cd "${dir}" || exit 1; pwd -P)
}
function .install.canonical-dir() {
local source=$(.install.canonical-source)
canonical-dir "$(dirname "${source}")"
}
function .install.print-directories() {
local dir="$(.install.canonical-dir)"
local source="$(.install.canonical-source)"
local source_script
[[ -n "${source}" ]] && source_script="$(basename "${source}")"
printf -- "BASH-install's directory : ${bldgrn}%-40s${clr}\n" "${dir}"
printf -- "BASH-install's full path : ${bldgrn}%-40s${clr}\n" "${dir}/${source_script}"
printf -- "Active shell right now : ${bldgrn}%-20s${clr}\n" "$(.install.current-shell | sed -E 's/[ ]//g' | tr -d ' ')"
}
function .install.header() {
printf -- "${bldwht}${bakred} ➜ Bashmatic Installer (verbose mode) ${clr}\n"
}
function .install.bashmatic-install() {
.install.parse-opts "$@" || return
((bootstrap__verbose)) && .install.header
((bootstrap__print)) && .install.print-directories
.install.os-requirements
((bootstrap__skip_install)) || .install.download-and-install
}
function bashmatic-install() {
.install.bashmatic-install "$@"
}
function .install.abort() {
echo
.err 'Aborting due to user action.'
trap '' INT
exit 127
}
len=${#BASH_SOURCE[@]}
last_index=$((len - 1))
[[ ${last_index} -lt 0 ]] && last_index=0
current_shell=$(.install.current-shell)
set +e
# Allow sourcing in bin/bashmatic-install and using it's shell functions, eg:
# source bin/bashmatic-install init
if [[ ${current_shell} =~ "bash" ]] && [[ -n ${BASH_VERSION} && "$0" != "${BASH_SOURCE[${last_index}]}" ]]; then
echo >/dev/null
elif [[ ${current_shell} =~ "zsh" ]] && [[ -n ${ZSH_EVAL_CONEXT} && ${ZSH_EVAL_CONTEXT} =~ :file$ ]]; then
echo >/dev/null
else
.install.bashmatic-install "$@"
fi