[PATCH] Prevent wordexp from modyfying terminal parameters
Moulding, Daniel - 0663 - MITLL
Tue Aug 3 18:16:00 GMT 2010
> Rather than redirecting stdin, would it be sufficient to add "-c" to
> the list of arguments passed to bash?
I'm not sure what the idea is. Isn't "-c" supposed to be followed-up with a
command to have Bash execute?
> Also, it is a bit faster to just close(STDIN_FILENO) (and start bash
> with closed stdin) than to dup2 an output-only pipe over to stdin
I tried this out and it seems to work.
My only concern with this would be if it could be potentially problematic to
start Bash with no valid stdin. Having it read EOF from a pipe (should it
attempt a read) is one thing, but having
read() return an error because stdin isn't open is something else. Not
saying it won't work, but somehow it just seems fragile to me. If nobody
else shares this concern, I'd be satisfied with this fix (assuming we've
otherwise correctly identified the root cause).
> You probably also want to file a bug report with bug-bash AT gnu DOT
> org that --wordexp should never need to do a check for interactive
> mode, since it is a special-purpose invocation mode not even
> documented in the man page.
I don't want to presume to tell the Bash folks how an *undocumented* feature
of their program should work :) But it does seem like a reasonable
expectation that when "--wordexp" is specified it shouldn't attempt any
interactive type stuff. Casually glancing over the Bash source, I saw that
it does key off of "--wordexp" as one way of turning on non-interactive
mode, so I'm not sure why the weird behavior.
In light of the other oddities I mentioned in my reply to Jeff, maybe
there's something else going on, and redirecting/closing stdin fixes the
problem for some other reason? Perhaps I haven't correctly identified the
root cause? I'm really not sure at this point.
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 5262 bytes
Desc: not available
More information about the Newlib