-
Notifications
You must be signed in to change notification settings - Fork 6
Implement alias/unalias builtin #2
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
base: master
Are you sure you want to change the base?
Conversation
|
@ashpil Have you had time to look at this? |
Oh wow this is amazing! I somehow completely missed this PR, thanks for pinging me again! Taking a look now. |
| Some(_) => match self.read_until(false, false, false, Box::new(is_token_split)) { | ||
| Ok(w) => { | ||
| println!("The words I got: {:?}", w); | ||
| debug_println!("The words I got: {:?}", w); |
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.
Whoops, this print statement did slid past me before I pushed. Thanks for catching it.
Honestly I'm not sure whether something like this makes sense as a debug_println, or if it should just be removed.
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.
Heheh, ok. I've left it in for now, feel free to remove it later.
|
Currently panics if such a sequence of commands is run: If you do the same thing in dash, it just does nothing. Edit: might be good to put a test case for this in along with the fix |
|
Looking at this, I think to me it might make more sense to do the parsing of the aliased command in the |
|
@emlun With the above comments, I think this PR should be good. Let me know if my comments make sense to you. And, thanks again for implementing this! It looks great. |
| ", | ||
| "$> $> alias bar='oche' | ||
| alias foo='echo' | ||
| $> $> $> $> alias bar='oche' |
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.
Why are there multiple $> on one line in some places? How does this work?
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.
As far as I can tell, the shell isn't printing newlines unless the command does (by using println! instead of print!, for example). In interactive mode, most newlines are entered by the user rather than printed by the shell.
|
Thanks for the review! I'll try to fix these things up in the next couple of days. |
Great! Make sure you rebase against master, as I just did a small commit, and run |
|
And you can check |
|
Alright, I think I've addressed all your comments now.
You mean parse the alias immediately when defined? Hmm... maybe? My first thought on that is that it could get weird because aliases can reference each other and include pipes/conjunctions, and you can also pass additional arguments after an alias. But maybe all you'd need to do is concatenate those additional arguments onto whatever's in the predefined |
Yeah, I think you could append the additional arguments into the predefined To me, it seems as if it would be a cleaner and more performant way of doing it. If you're not up to it, that's fine. We can just get this merged in, and I can take a look at it myself later. |
|
I took a stab at it and quickly ran into a couple of nontrivial issues. 🙂 For starters you'll have to pass the whole |
|
Passing in the |
|
Hm... oh yeah, you're probably right. I figured I'd need to construct a |
|
Okay, here are the changes I ended up with to make that happen. What do you think, should I pull that in here? |
I think that's better! A couple things:
These things make me think that there would be way too much code for this in the runner. I think it might be smarter to just move the current Something that's subjective and doesn't necessarily need to be implemented now: I think instead of |
|
That all sounds like good points and good ideas, thanks! I'll look into that. |
Hello and happy Hacktoberfest! Here's a stab at implementing the
alias/unaliasbuiltin, along with a necessary bug fix (see 921fbeb and 7d0511f) and some basic integration tests. I also extracted adebug_println!macro to make the assertions for those tests a bit cleaner.What do you think?