[darcs-devel] [issue1648] darcs apply -i tries to read user input from stdin (breaks redirection)
Judah Jacobson
bugs at darcs.net
Tue Mar 23 07:14:55 UTC 2010
Judah Jacobson <judah.jacobson at gmail.com> added the comment:
On Mon, Mar 22, 2010 at 5:45 AM, Eric Kow <bugs at darcs.net> wrote:
>
> Our conclusion was that before we need to research the problem more, and
> determine if there was a portable way to reliably detect if we were on a
> terminal or not. Windows may be an issue here.
>
> If there is one, we can re-open the discussion about how apply -i should
> behave.
>
> Judah: any chance you'd be able to look into this?
Sure. There's a Windows equivalent to /dev/tty ("CONIN$" and
"CONOUT$"); Haskeline already uses the latter but not yet the former.
I did some tests, and trying to open CONIN looks like a reliable way
to check whether we're in a console session.*
So I believe there's no technical barriers to a robust
terminal-checking in the backend of Haskeline. The best approach
seems to me to add a function to Haskeline's API. For example:
runInputTInTerm :: Settings m -> InputT m a -> m (Maybe a)
which tries to run the given action(s) using the terminal, even if
it's not stdin; and returns Nothing if it couldn't connect to
[/dev/tty,CONIN$]. This should give Darcs some flexibility in
deciding the exact semantics of apply -i.
*The one caveat: in a Cygwin X shell, we can't connect to CONIN. But
Haskeline doesn't provide any interactive editing in that setting
anyway, so this seems OK to me. (There's little I can do about that
unless GHC improves its Cygwin support.)
__________________________________
Darcs bug tracker <bugs at darcs.net>
<http://bugs.darcs.net/issue1648>
__________________________________
More information about the darcs-devel
mailing list