summaryrefslogtreecommitdiffstats
path: root/diagnostics
diff options
context:
space:
mode:
authorEthan P <32112321+eth-p@users.noreply.github.com>2020-04-20 23:33:44 -0700
committerGitHub <noreply@github.com>2020-04-21 08:33:44 +0200
commit96aedf624031901c34763fa44513628e23ded6ca (patch)
tree2c003733881ceb36c37da89743865ff830338668 /diagnostics
parent4cc2989fe95b064baeee09e1f57586c74e2ce043 (diff)
Add cat alias detection to info.sh (#911)
Diffstat (limited to 'diagnostics')
-rwxr-xr-xdiagnostics/info.sh49
1 files changed, 28 insertions, 21 deletions
diff --git a/diagnostics/info.sh b/diagnostics/info.sh
index 25f9b94b..a4c6b52c 100755
--- a/diagnostics/info.sh
+++ b/diagnostics/info.sh
@@ -71,27 +71,34 @@ _bat_wrapper_:run() {
}
_bat_wrapper_function_:run() {
- case "$("$SHELL" --version | head -n 1)" in
- *fish*)
- if "$SHELL" --login -i -c 'type bat' 2>&1 | grep 'function' &> /dev/null; then
- _out_fence "$SHELL" --login -c 'functions bat'
- return
- fi
- ;;
-
- *bash* | *zsh*)
- if "$SHELL" --login -i -c 'type bat' 2>&1 | grep 'function' &> /dev/null; then
- _out_fence "$SHELL" --login -i -c 'declare -f bat'
- return
- fi
- ;;
-
- *)
- echo "Unable to determine if a wrapper function is set."
- return
- ;;
- esac
- printf "\nNo wrapper function.\n"
+ _bat_wrapper_function_:detect_wrapper() {
+ local command="$1"
+ case "$("$SHELL" --version | head -n 1)" in
+ *fish*)
+ if "$SHELL" --login -i -c "type ${command}" 2>&1 | grep 'function' &>/dev/null; then
+ _out_fence "$SHELL" --login -i -c "functions ${command}"
+ return
+ fi ;;
+
+ *bash*|*zsh*)
+ local type="$("$SHELL" --login -i -c "type ${command}" 2>&1)"
+ if grep 'function' <<< "$type" &>/dev/null; then
+ _out_fence "$SHELL" --login -i -c "declare -f ${command}"
+ return
+ elif grep 'alias' <<< "$type" &>/dev/null; then
+ _out_fence "$SHELL" --login -i -c "type ${command}"
+ return
+ fi ;;
+
+ *)
+ echo "Unable to determine if a wrapper function for '${command}' is set."
+ return ;;
+ esac
+ printf "\nNo wrapper function for '%s'.\n" "${command}"
+ }
+
+ _bat_wrapper_function_:detect_wrapper bat
+ _bat_wrapper_function_:detect_wrapper cat
}
_system_:run() {