build: Add support for more alt executables

This commit is contained in:
Ethan P 2023-05-15 19:47:19 -07:00
parent 3e7041da7b
commit 7107e1603f
No known key found for this signature in database
GPG Key ID: B29B90B1B228FEBC
2 changed files with 16 additions and 7 deletions

View File

@ -145,6 +145,7 @@ This is a beta feature that uses a non-compliant Markdown "parser" written in Ba
Depending on the distribution, bat may have been renamed to avoid package conflicts. Depending on the distribution, bat may have been renamed to avoid package conflicts.
If you wish to use these scripts on a distribution where this is the case, there is an `--alternate-executable=NAME` option which will build the scripts to use an alternate executable name. If you wish to use these scripts on a distribution where this is the case, there is an `--alternate-executable=NAME` option which will build the scripts to use an alternate executable name.
You may also specify alternate executables for `ripgrep`, `delta`, `fzf`, or `git` with `--alternate-executable:PROGRAM NAME` where `PROGRAM` is one the aforementioned programs. Note that doing so may cause verification to fail.
**Verification:** **Verification:**

View File

@ -417,7 +417,8 @@ OPT_MANUALS=true
OPT_INLINE=true OPT_INLINE=true
OPT_MINIFY="lib" OPT_MINIFY="lib"
OPT_PREFIX="/usr/local" OPT_PREFIX="/usr/local"
OPT_BAT="$(basename "$EXECUTABLE_BAT")" EXECUTABLE_BAT="$(basename -- "$EXECUTABLE_BAT")"
ALT_EXECS=()
BUILD_FILTER=() BUILD_FILTER=()
DOCS_URL="https://github.com/eth-p/bat-extras/blob/master/doc" DOCS_URL="https://github.com/eth-p/bat-extras/blob/master/doc"
@ -437,7 +438,12 @@ while shiftopt; do
--inline) OPT_INLINE=true ;; --inline) OPT_INLINE=true ;;
--no-inline) OPT_INLINE=false ;; --no-inline) OPT_INLINE=false ;;
--prefix) shiftval; OPT_PREFIX="$OPT_VAL" ;; --prefix) shiftval; OPT_PREFIX="$OPT_VAL" ;;
--alternate-executable) shiftval; OPT_BAT="$OPT_VAL" ;; --alternate-executable) shiftval; ALT_EXECS+=("bat"); EXECUTABLE_BAT="$OPT_VAL" ;;
--alternate-executable:bat) shiftval; ALT_EXECS+=("bat"); EXECUTABLE_BAT="$OPT_VAL" ;;
--alternate-executable:ripgrep) shiftval; ALT_EXECS+=("ripgrep"); EXECUTABLE_RIPGREP="$OPT_VAL" ;;
--alternate-executable:delta) shiftval; ALT_EXECS+=("delta"); EXECUTABLE_DELTA="$OPT_VAL" ;;
--alternate-executable:fzf) shiftval; ALT_EXECS+=("fzf"); EXECUTABLE_FZF="$OPT_VAL" ;;
--alternate-executable:git) shiftval; ALT_EXECS+=("git"); EXECUTABLE_GIT="$OPT_VAL" ;;
--minify) shiftval; OPT_MINIFY="$OPT_VAL" ;; --minify) shiftval; OPT_MINIFY="$OPT_VAL" ;;
*) *)
@ -451,15 +457,17 @@ while shiftopt; do
esac esac
done done
if [[ "$OPT_BAT" != "bat" ]]; then if [[ "${#ALT_EXECS[@]}" -gt 0 ]]; then
printc_msg "%{YELLOW}Building executable scripts with an alternate bat executable %{CLEAR}%s%{YELLOW}.%{CLEAR}\n" "$OPT_BAT" printc_msg "%{YELLOW}Building executable scripts with alternate executables for:%{CLEAR}\n"
if ! command -v "$OPT_BAT" &>/dev/null; then printc_msg "%{YELLOW} - %{CLEAR}%s\n" "${ALT_EXECS[@]}"
printc_err "%{YELLOW}WARNING: Bash cannot execute the specified file.\n" printc_msg "\n"
if ! command -v "$EXECUTABLE_BAT" &>/dev/null; then
printc_err "%{YELLOW}WARNING: Bash cannot execute bat's executable file.\n"
printc_err "%{YELLOW} The finished scripts may not run properly.%{CLEAR}\n" printc_err "%{YELLOW} The finished scripts may not run properly.%{CLEAR}\n"
fi fi
# shellcheck disable=SC2034 # shellcheck disable=SC2034
EXECUTABLE_BAT="$OPT_BAT"
printc_msg "\n" printc_msg "\n"
fi fi