skywind3000 / z.lua

:zap: A new cd command that helps you navigate faster by learning your habits.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

--init show zsh: parse error near `>&'

alps2006 opened this issue · comments

A strange problem on z.lua --init

z.lua$ eval "$(lua z.lua --init)" 
# output error
zsh: parse error near `>&'

I found the error location at -h|--help) local arg_mode="-h" ;;, and i resolved by escaping --help , but why only --help?

M z.lua
@@ -2188,7 +2188,7 @@ _zlua() {
 			-s) local arg_strip="-s" ;;
 			-i) local arg_inter="-i" ;;
 			-I) local arg_inter="-I" ;;
-			-h|--help) local arg_mode="-h" ;;
+			-h|\--help) local arg_mode="-h" ;;
 			--purge) local arg_mode="--purge" ;;
 			*) break ;;
 		esac

which version of zsh are you using?
I haven't encountered this before in zsh.

Thanks for your reply, the detail is below.

~/Documents/markdown ❯ zsh  --version
zsh 5.9 (x86_64-apple-darwin23.0.0)
~/Documents/markdown ❯ type -a zsh
zsh is /opt/local/bin/zsh
zsh is /bin/zsh
zsh is /opt/local/bin/zsh
zsh is /bin/zsh
zsh is /opt/local/bin/zsh

I am not sure if there is some side effect (mostly in other shells) when changing -- to \--.
so I made another revise, please try out the latest version:

7c890c3

I have found the reason why i cannot use --help only, because there is a global alias that overrides --help entirely.

# bat to render --help
alias -g -- --help='--help 2>&1 | bat --language=help --style=plain'

thank you very much, i close it.