Open yanok opened 3 years ago
Yes, PR is welcome.
I am not sure I understand the
Using CMD_EXPANDED=$3 instead of CMD_EXPANDED=$2
part, but let's see in the PR if I get it.
(2) seems sensible.
Regarding CMD_EXPANDED=$3
, from zsh doc (http://zsh.sourceforge.net/Doc/Release/Functions.html):
The actual command that will be executed (including expanded aliases) is passed in two different forms: the second argument is a single-line, size-limited version of the command (with things like function bodies elided); the third argument contains the full text that is being executed.
What I experience currently is long commands are falsely detected as aliases. I believe this is exactly because the second argument to the hook is size-limited.
I've found some unexpected "Alias for:" messages, especially while running particularly long commands:
I believe this is because the second argument to the preexec hook can be trimmed and what we really want is to compare the command with the third argument, which is not trimmed.
Another issue is with
export
(maybe some other builtins too, but I've only seen export so far):This one is because expanded command for some reason has a trailing whitespace. I'm not sure, maybe this is actually a zsh bug, but we can easily workaround this by removing the trailing whitespace before doing comparison.
Would you be interested in PRs to fix that? Any objections to
CMD_EXPANDED=$3
instead ofCMD_EXPANDED=$2