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

&> output redirection operator incorrectly parsed #90

Closed
timetoplatypus opened this Issue Mar 21, 2018 · 5 comments

Comments

Projects
None yet
2 participants
@timetoplatypus
Contributor

timetoplatypus commented Mar 21, 2018

$> bin/osh
osh$ pushd /home &> /dev/null
Started background job with pid 19099
/home ~/Documents
osh$

I see that there's a spec test for this already (it's failing) so this is really just a feature request. The ampersand is being parsed as a "hey execute this stuff in a background job" instead of recognizing that I'm trying to redirect stdout and stderr.

I have a script that uses pushd in a similar manner as in the above example. It has this problem where instead of actually changing directories, it executes that pushd in a background job and when it exits the background job I'm left back in the directory I started. If you can fix this behavior, I'd be able to use my script in OSH which would be nice.

@timetoplatypus

This comment has been minimized.

Show comment
Hide comment
@timetoplatypus

timetoplatypus Mar 21, 2018

Contributor

Natural follow-on question (I can move it to the mailing list if that would be better suited): are there plans to add a fg command to bring background jobs to the foreground?

Contributor

timetoplatypus commented Mar 21, 2018

Natural follow-on question (I can move it to the mailing list if that would be better suited): are there plans to add a fg command to bring background jobs to the foreground?

@andychu

This comment has been minimized.

Show comment
Hide comment
@andychu

andychu Mar 21, 2018

Contributor

Thanks for the request -- I think &> should be pretty easy to implement. I haven't seen it used before!

As far as fg, yes we should have it. I don't quite understand the system calls you need to make to implement it. My understanding is that

$ sleep 1 &

does two things:

  1. It doesn't wait until the sleep is done to continue running the script. That is, it does fork(), but not wait().
  2. It detaches the process from the terminal (somehow)

Then fg somehow attached it back to the terminal. But my memory of how this happens is fuzzy.

But yes, there's no reason that fg can't be supported eventually.

One thing that is likely to push it to the back of the queue is that I'm a tmux user :) I don't use shell job control -- I just start a new shell in tmux. So if you or anyone else wants to help that would be nice :)

I'm also not sure if it's easier to do in C or in Python.

Contributor

andychu commented Mar 21, 2018

Thanks for the request -- I think &> should be pretty easy to implement. I haven't seen it used before!

As far as fg, yes we should have it. I don't quite understand the system calls you need to make to implement it. My understanding is that

$ sleep 1 &

does two things:

  1. It doesn't wait until the sleep is done to continue running the script. That is, it does fork(), but not wait().
  2. It detaches the process from the terminal (somehow)

Then fg somehow attached it back to the terminal. But my memory of how this happens is fuzzy.

But yes, there's no reason that fg can't be supported eventually.

One thing that is likely to push it to the back of the queue is that I'm a tmux user :) I don't use shell job control -- I just start a new shell in tmux. So if you or anyone else wants to help that would be nice :)

I'm also not sure if it's easier to do in C or in Python.

@andychu

This comment has been minimized.

Show comment
Hide comment
@andychu

andychu Mar 21, 2018

Contributor

Oh also if you need fg, please make a separate issue for it -- otherwise it will get lose under &>.

Contributor

andychu commented Mar 21, 2018

Oh also if you need fg, please make a separate issue for it -- otherwise it will get lose under &>.

@andychu andychu changed the title from '&' output redirection operator incorrectly parsed to &> output redirection operator incorrectly parsed Mar 21, 2018

@timetoplatypus

This comment has been minimized.

Show comment
Hide comment
@timetoplatypus

timetoplatypus Mar 22, 2018

Contributor

I don't need fg, I was just curious. I too am a heavy tmux (and wemux user) as well.

Contributor

timetoplatypus commented Mar 22, 2018

I don't need fg, I was just curious. I too am a heavy tmux (and wemux user) as well.

andychu pushed a commit that referenced this issue May 1, 2018

@andychu

This comment has been minimized.

Show comment
Hide comment
@andychu

andychu May 1, 2018

Contributor

Hm this was easier than I thought, but unfortunately it didn't make it into the release. I'll think about doing another release before August.

Maybe I'll strip down the interpreter some more to make it worth it.

Contributor

andychu commented May 1, 2018

Hm this was easier than I thought, but unfortunately it didn't make it into the release. I'll think about doing another release before August.

Maybe I'll strip down the interpreter some more to make it worth it.

@andychu andychu closed this Jul 24, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment