Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unexpected "reveals" for non-aliases #55

Open
yanok opened this issue Apr 17, 2021 · 2 comments
Open

Unexpected "reveals" for non-aliases #55

yanok opened this issue Apr 17, 2021 · 2 comments

Comments

@yanok
Copy link

yanok commented Apr 17, 2021

I've found some unexpected "Alias for:" messages, especially while running particularly long commands:

$ echo longlonglonglonglonglonglong linelinelinelinelinelinelinelinelinelineline
Alias for: echo longlonglonglonglonglonglong linelinelinelinelinelinelinelinelinelinelin 
longlonglonglonglonglonglong linelinelinelinelinelinelinelinelinelineline

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):

$ export TEST=x                                                                   
Alias for: export TEST=x  

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

  1. Using CMD_EXPANDED=$3 instead of CMD_EXPANDED=$2
  2. Removal trailing whitespace from CMD/CMD_EXPANDED?
@djui
Copy link
Owner

djui commented Apr 19, 2021

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.

@yanok
Copy link
Author

yanok commented Apr 19, 2021

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants