-
Notifications
You must be signed in to change notification settings - Fork 11
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
Replace ~ with homedir #49
Conversation
At first I thought we can do the replacement while parsing and that way |
I don't think it is hard to support. Rather, it makes it impossible to expand ~ to homedir at parsing time. I believe there are other examples too where an unquoted ~ is not directly expanded. Hence, I think what I just implemented, only expands ~ in commands where it should be. With this implementation, we can support |
Hmm, complicated. I wonder if we should treat it as a special token. The following behavior is observed in zsh:
So only when |
PS: I haven't tested your branch yet! So maybe it works already exactly as bash here. |
arg.to_string() | ||
}; | ||
args.push(OsString::from(expanded_arg)); | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think ls should not be handling ~
explicitly.
I think it's time to step back and separate parsing, semantics and execution. The parser should take care of handling The semantic phase goes over the AST and checks all semantics (such as: are options valid for "ls", "cd" and other commands). It should create an IR (intermediate representation) that is semantically valid. Conceptually we then need to add several IR->IR passes:
The backend then takes the IR and executes. Ideally it does not handle any We then have a choice: either we have an explicit IR->IR passes, or we can merge them with AST->IR, or with IR->backend. However, conceptually (in our head) we should think of these operations as independent, standalone IR->IR passes. I made this #70. |
Yes, that is correct.
|
Ah great, the reference you found is indeed pretty clear :) |
I have moved this to draft for now. I will try to expand during parsing just as @certik mentioned. |
I think the pest grammar should turn this into something like |
I was suggesting NOT to expand during parsing, but rather create a |
As an extension to #37 and fix for #44