-
-
Notifications
You must be signed in to change notification settings - Fork 158
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
Take a stab at PROMPT_COMMAND #414
Conversation
Location information is wrong - PROMPT_COMMAND=';' gives a traceback pointing to ~/.local/oil/oshrc instead of [ interactive ] or [ PROMPT_COMMAND ] Addresses oils-for-unix#400
I think this needs to be similar in spirit to WordParser.EvalForPlugin() and Tracer in core/dev.py. PS4 is evaluating something for every line for For example I believe it should avoid changing That said, if you can add a test case in |
- Don't let command change status - Handle arrays. Previously, osh would crash on `PROMPT_COMMAND=(1 2 3)`
My local |
I usually do something like:
Does that work? |
Hmm, that worked which makes me confused why the tests aren't passing. I'm running
Running the command through spec.sh:
Running manually:
|
OK weird, I reproduced this on another machine. Let me see what's going on! |
Weirdly it works on Travis: |
I don't understand why https://askubuntu.com/questions/22607/remove-note-about-sudo-that-appears-when-opening-the-terminal |
OK I think this is system bash vs. hermetic bash from I think Ubuntu must have patched bash to run
Here's my Ubuntu:
|
I mention the https://github.com/oilshell/oil/wiki/Spec-Tests I guess you just have to compile bash once, and it should go away. And it's better to do that anyway so all the rest of the tests pass. There are definitely differences between bash 4.3 and bash 4.4, so if your system has 4.3 it's worth the time. |
- Set $HOME variable so bash doesn't print message about sudo. See oils-for-unix#414 (comment) - Don't source startup files, they could print a message (and in my case, did)
I set |
I added a test case, could you take another look? |
case $SH in | ||
*bash) echo "$TEST_CASE" | $SH --noprofile --norc -i;; | ||
*osh) $SH --rcfile /dev/null -i -c "$TEST_CASE";; | ||
*) $SH -i -c "$TEST_CASE";; |
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.
Hm also this seems to be doing a ton of stuff that's different for each shell, which makes the validity of the test hard to gauge at a glance.
Are you trying to avoid the spurious stdout from bash?
If doing the test/spec-bin.sh
stuff in your environment fixes it, then please do that instead.
I added test/spec.sh interactive
on Travis, and it doesn't have that problem. For now that is sort of the "golden environment".
If for some reason you can't get a _tmp/spec-bin/bash
, or the instructions don't make sense, let me know.
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.
Yes that should have been commented. This isn't an issue with spurious output, this is because osh and bash have different ideas of what it means to be interactive.
bash -i -c 'PROMPT_COMMAND="echo hi"'
does not give any output, but echo 'PROMPT_COMMAND="echo hi"'' | bash -i
does.
osh goes the other way and prints the prompt:
$ echo 'PROMPT_COMMAND="echo hi"' | osh -i
osh$ hi
osh$ ^D
$
I agree not having the same test for both isn't ideal but I didn't see another way to check this.
Speaking of exceptions, this patch crashes osh if PROMPT_COMMAND throws an exception:
I'm looking into how |
I'm not sure how to treat the word returned by EvalForPlugin as a command substitution, I have the following code but it just prints the word instead of running a command.
|
I think that behavior is OK for now. I will probably do some refactoring, i.e. instead of _Eval, add something like RunFuncForCompletion. But if some new tests pass, then I won't worry too much about the details. OK thanks for letting me know about the bash/osh difference. Please add a comment about that in the test. My main issue now is setting $HOME because your version of bash is reading a file in We could set $HOME to something I think it will pass on Travis without that, so please remove it for now, and then we can figure out what to do if it's still failing on your machine. |
Avoids dependence on files in HOME. Requested in oils-for-unix#414 (comment)
Ok I took HOME out, let me know if there's any more changes I should make. Yup, building from source fixed it. Maybe we should add that to the wiki? |
Great, yes feel free to update the wiki! |
BTW I got the tests working roughly the same under bash/OSH: Thanks for adding this! |
Location information is wrong - PROMPT_COMMAND=';' gives a traceback
pointing to ~/.local/oil/oshrc instead of [ interactive ] or
[ PROMPT_COMMAND ]
Other than that, this seems to be working pretty well with my patched version of bash-git-prompt.
Addresses #400