mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 16:47:36 +00:00
Meta: Tweak shell_include.sh
* `chmod -x` as it's for sourcing, not for executing * Remove run line, for the same reason * Rename it from .shell_include.sh to shell_include.sh, since e.g. `rg` doesn't search in hidden files by default No behavior change.
This commit is contained in:
parent
9a2ee5a9dd
commit
c6f81b5b83
6 changed files with 6 additions and 6 deletions
53
Meta/shell_include.sh
Normal file
53
Meta/shell_include.sh
Normal file
|
@ -0,0 +1,53 @@
|
|||
# shellcheck shell=bash
|
||||
# shellcheck disable=SC2034
|
||||
# SC2034: "Variable appears unused. Verify it or export it."
|
||||
# Those are intentional here, as the file is meant to be included elsewhere.
|
||||
|
||||
# NOTE: If using another privilege escalation binary make sure it is configured or has the appropiate flag
|
||||
# to keep the current environment variables in the launched process (in sudo's case this is achieved
|
||||
# through the -E flag described in sudo(8).
|
||||
SUDO="sudo -E"
|
||||
|
||||
if [ "$(uname -s)" = "SerenityOS" ]; then
|
||||
SUDO="pls -E"
|
||||
fi
|
||||
|
||||
die() {
|
||||
echo "die: $*"
|
||||
exit 1
|
||||
}
|
||||
|
||||
find_executable() {
|
||||
paths=("/usr/sbin" "/sbin")
|
||||
|
||||
if [ "$(uname -s)" = "Darwin" ]; then
|
||||
if [ -n "${HOMEBREW_PREFIX}" ]; then
|
||||
paths+=("${HOMEBREW_PREFIX}/opt/e2fsprogs/bin" "${HOMEBREW_PREFIX}/opt/e2fsprogs/sbin")
|
||||
elif command -v brew > /dev/null 2>&1; then
|
||||
if prefix=$(brew --prefix e2fsprogs 2>/dev/null); then
|
||||
paths+=("${prefix}/bin" "${prefix}/sbin")
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
executable="${1}"
|
||||
|
||||
# Prefer tools from PATH over fallback paths
|
||||
if command -v "${executable}"; then
|
||||
return 0
|
||||
fi
|
||||
|
||||
for path in "${paths[@]}"; do
|
||||
if command -v "${path}/${executable}"; then
|
||||
return 0
|
||||
fi
|
||||
done
|
||||
|
||||
# We return the executable's name back to provide meaningful messages on future failure
|
||||
echo "${executable}"
|
||||
}
|
||||
|
||||
FUSE2FS_PATH="$(find_executable fuse2fs)"
|
||||
RESIZE2FS_PATH="$(find_executable resize2fs)"
|
||||
E2FSCK_PATH="$(find_executable e2fsck)"
|
||||
MKE2FS_PATH="$(find_executable mke2fs)"
|
Loading…
Add table
Add a link
Reference in a new issue