From 81d9fc2095becd2f56beac52989807b55936f815 Mon Sep 17 00:00:00 2001 From: Frank Terbeck Date: Sun, 7 Jun 2009 12:56:37 +0200 Subject: [PATCH] zshrc: Give check_com a -g option to test for global aliases, too. --- debian/changelog | 3 ++- etc/zsh/zshrc | 12 +++++++++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/debian/changelog b/debian/changelog index f742e72..47e3b9a 100644 --- a/debian/changelog +++ b/debian/changelog @@ -5,12 +5,13 @@ grml-etc-core (0.3.73) UNRELEASED; urgency=low to hang forever. Reported by Rasmus Steinke. * zshrc: Fix problems related to TERM=mostlike in zshrc. Again reported by Rasmus Steinke. + * zshrc: Give check_com a -g option to test for global aliases, too. [ Michael Prokop ] * zshrc: add deborphan, pal and hnb to compdef _gnu_generic. Thanks for the suggestion to Carsten Hey. - -- Michael Prokop Fri, 05 Jun 2009 09:35:58 +0200 + -- Frank Terbeck Sun, 07 Jun 2009 12:55:15 +0200 grml-etc-core (0.3.72) unstable; urgency=low diff --git a/etc/zsh/zshrc b/etc/zsh/zshrc index 30922f7..06523f6 100644 --- a/etc/zsh/zshrc +++ b/etc/zsh/zshrc @@ -332,14 +332,20 @@ fi # GRML_WARN_SKEL # this function checks if a command exists and returns either true # or false. This avoids using 'which' and 'whence', which will # avoid problems with aliases for which on certain weird systems. :-) +# Usage: check_com [-c|-g] word +# -c only checks for external commands +# -g does the usual tests and also checks for global aliases check_com() { - local -i comonly + local -i comonly gatoo if [[ ${1} == '-c' ]] ; then (( comonly = 1 )) shift + elif [[ ${1} == '-g' ]] ; then + (( gatoo = 1 )) else (( comonly = 0 )) + (( gatoo = 0 )) fi if (( ${#argv} != 1 )) ; then @@ -360,6 +366,10 @@ check_com() { return 0 fi + if (( gatoo > 0 )) && [[ -n ${galiases[$1]} ]] ; then + return 0 + fi + return 1 } -- 2.1.4