mirror of
https://github.com/natelandau/shell-scripting-templates.git
synced 2025-11-08 21:23:48 -05:00
add _homebrewPath_
This commit is contained in:
@@ -247,6 +247,7 @@ Functions useful when writing scripts to be run on macOS
|
|||||||
|
|
||||||
- **`_guiInput_`** Ask for user input using a Mac dialog box
|
- **`_guiInput_`** Ask for user input using a Mac dialog box
|
||||||
- **`_haveScriptableFinder_`** Determine whether we can script the Finder or not
|
- **`_haveScriptableFinder_`** Determine whether we can script the Finder or not
|
||||||
|
- **`_homebrewPath_`** Adds Homebrew bin directory to PATH
|
||||||
- **`_useGNUUtils_`** Add GNU utilities to PATH to allow consistent use of sed/grep/tar/etc. on MacOS
|
- **`_useGNUUtils_`** Add GNU utilities to PATH to allow consistent use of sed/grep/tar/etc. on MacOS
|
||||||
|
|
||||||
## misc.bash
|
## misc.bash
|
||||||
|
|||||||
@@ -359,7 +359,10 @@ _parseOptions_ "$@"
|
|||||||
# Acquire script lock
|
# Acquire script lock
|
||||||
# _acquireScriptLock_
|
# _acquireScriptLock_
|
||||||
|
|
||||||
# Source GNU utilities for use on MacOS
|
# Add Homebrew bin directory to PATH (MacOS)
|
||||||
|
# _homebrewPath_
|
||||||
|
|
||||||
|
# Source GNU utilities from Homebrew (MacOS)
|
||||||
# _useGNUutils_
|
# _useGNUutils_
|
||||||
|
|
||||||
# Run the main logic script
|
# Run the main logic script
|
||||||
|
|||||||
@@ -350,6 +350,28 @@ _makeTempDir_() {
|
|||||||
debug "\$TMP_DIR=${TMP_DIR}"
|
debug "\$TMP_DIR=${TMP_DIR}"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_homebrewPath_() {
|
||||||
|
# DESC:
|
||||||
|
# Add homebrew bin dir to PATH
|
||||||
|
# ARGS:
|
||||||
|
# None
|
||||||
|
# OUTS:
|
||||||
|
# 0 if successful
|
||||||
|
# 1 if unsuccessful
|
||||||
|
# PATH: Adds homebrew bin directory to PATH
|
||||||
|
# USAGE:
|
||||||
|
# # if ! _homebrewPath_; then exit 1; fi
|
||||||
|
|
||||||
|
! declare -f "_setPATH_" &>/dev/null && fatal "${FUNCNAME[0]} needs function _setPATH_"
|
||||||
|
|
||||||
|
if _setPATH_ "/usr/local/bin" "/opt/homebrew/bin"; then
|
||||||
|
return 0
|
||||||
|
else
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
# shellcheck disable=SC2120
|
# shellcheck disable=SC2120
|
||||||
_acquireScriptLock_() {
|
_acquireScriptLock_() {
|
||||||
# DESC:
|
# DESC:
|
||||||
@@ -391,7 +413,7 @@ _setPATH_() {
|
|||||||
# ARGS:
|
# ARGS:
|
||||||
# $@ - One or more paths
|
# $@ - One or more paths
|
||||||
# OPTS:
|
# OPTS:
|
||||||
# -x - Fail if directories are not found
|
# -x Fail if directories are not found
|
||||||
# OUTS:
|
# OUTS:
|
||||||
# 0: Success
|
# 0: Success
|
||||||
# 1: Failure
|
# 1: Failure
|
||||||
@@ -637,8 +659,11 @@ _parseOptions_ "$@"
|
|||||||
# Acquire script lock
|
# Acquire script lock
|
||||||
# _acquireScriptLock_
|
# _acquireScriptLock_
|
||||||
|
|
||||||
# Source GNU utilities for use on MacOS
|
# Add Homebrew bin directory to PATH (MacOS)
|
||||||
_useGNUutils_
|
# _homebrewPath_
|
||||||
|
|
||||||
|
# Source GNU utilities from Homebrew (MacOS)
|
||||||
|
# _useGNUutils_
|
||||||
|
|
||||||
# Run the main logic script
|
# Run the main logic script
|
||||||
_mainScript_
|
_mainScript_
|
||||||
|
|||||||
@@ -81,3 +81,25 @@ _useGNUutils_() {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_homebrewPath_() {
|
||||||
|
# DESC:
|
||||||
|
# Add homebrew bin dir to PATH
|
||||||
|
# ARGS:
|
||||||
|
# None
|
||||||
|
# OUTS:
|
||||||
|
# 0 if successful
|
||||||
|
# 1 if unsuccessful
|
||||||
|
# PATH: Adds homebrew bin directory to PATH
|
||||||
|
# USAGE:
|
||||||
|
# # if ! _homebrewPath_; then exit 1; fi
|
||||||
|
|
||||||
|
! declare -f "_setPATH_" &>/dev/null && fatal "${FUNCNAME[0]} needs function _setPATH_"
|
||||||
|
|
||||||
|
if _setPATH_ "/usr/local/bin" "/opt/homebrew/bin"; then
|
||||||
|
return 0
|
||||||
|
else
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user