mirror of
https://github.com/natelandau/shell-scripting-templates.git
synced 2025-11-08 13:13:47 -05:00
Cnofirm directories exist before adding to PATH
This commit is contained in:
@@ -237,10 +237,11 @@ _testSeekConfirmation_() {
|
|||||||
|
|
||||||
_testSetPATH_() {
|
_testSetPATH_() {
|
||||||
@test "_setPATH_" {
|
@test "_setPATH_" {
|
||||||
_setPATH_ "/testing/from/bats" "/testing/again"
|
mkdir -p "${TESTDIR}/testing/from/bats"
|
||||||
run echo "$PATH"
|
_setPATH_ "${TESTDIR}/testing/from/bats" "${TESTDIR}/testing/again"
|
||||||
|
run echo "${PATH}"
|
||||||
assert_output --regexp "/testing/from/bats"
|
assert_output --regexp "/testing/from/bats"
|
||||||
assert_output --regexp "/testing/again"
|
refute_output --regexp "/testing/again"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -326,9 +326,11 @@ _setPATH_() {
|
|||||||
done
|
done
|
||||||
|
|
||||||
for NEWPATH in "${NEWPATHS[@]}"; do
|
for NEWPATH in "${NEWPATHS[@]}"; do
|
||||||
if ! echo "$PATH" | grep -Eq "(^|:)${NEWPATH}($|:)"; then
|
if [ -d "${NEWPATH}" ]; then
|
||||||
PATH="${NEWPATH}:${PATH}"
|
if ! echo "$PATH" | grep -Eq "(^|:)${NEWPATH}($|:)"; then
|
||||||
debug "Added '${tan}${NEWPATH}${purple}' to PATH"
|
PATH="${NEWPATH}:${PATH}"
|
||||||
|
debug "Added '${NEWPATH}' to PATH"
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user