Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

don't burden zsh with "_sub_wrapper" hack for bash #33

Closed
wants to merge 1 commit into from

1 participant

@mislav

Also, possibly enables again the wrapper function for shells other than
bash/zsh.

References #32, 212ac13

@mislav mislav don't burden zsh with "_sub_wrapper" hack for bash
Also, possibly enables again the wrapper function for shells other than
bash/zsh.
6fc8e6b
@mislav

Closing since outdated and not too critical.

@mislav mislav closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Jan 7, 2013
  1. @mislav

    don't burden zsh with "_sub_wrapper" hack for bash

    mislav authored
    Also, possibly enables again the wrapper function for shells other than
    bash/zsh.
This page is out of date. Refresh to see the latest.
Showing with 7 additions and 12 deletions.
  1. +7 −12 libexec/sub-init
View
19 libexec/sub-init
@@ -63,10 +63,14 @@ bash | zsh )
;;
esac
+wrapper_function=
+# hack for bash where numbers are not valid function name
+[ "$shell" = "bash" ] && wrapper_function=_sub_wrapper
+
commands=(`sub commands --sh`)
IFS="|"
cat <<EOS
-_sub_wrapper() {
+${wrapper_function:-sub}() {
local command="\$1"
if [ "\$#" -gt 0 ]; then
shift
@@ -81,14 +85,5 @@ _sub_wrapper() {
}
EOS
-# zsh can't pass argument with aliases, but bash can.
-# zsh can have functions with the name being only numbers, but bash can't.
-# fix both cases here by letting zsh have a function, and bash have its alias.
-case "$shell" in
-bash )
- echo "alias sub=_sub_wrapper"
- ;;
-zsh )
- echo "sub=_sub_wrapper"
- ;;
-esac
+# related to the bash hack above
+[ -n "$wrapper_function" ] && echo "alias sub=${wrapper_function}"
Something went wrong with that request. Please try again.