On Sun, Oct 11, 2009 at 8:16 AM, Eric Kow <[email protected]> wrote: > On Sun, Oct 11, 2009 at 08:02:33 +0000, Trent W. Buck wrote: >> When "apply interactive" is in ~/.darcs/defaults, patches cannot be >> read from standard input. This breaks workflows in e.g. mutt.
Is the workflow essentially "mutt <args> | darcs apply" in the bash shell? If not, can you elaborate? > Oh! That's worth keeping in mind for folks (like me) who want apply > -i to be default > >> It might seem counterintuitive to have "two" input streams, but >> clearly something like this can be implemented, because less(1) does >> it. For example, "dmesg | less" will let you scroll up and down, >> which presumably is reading the arrow keypresses from stdin. > > less(1) may not be reading its keypresses from stdin but directly from > the terminal (I'm not sure if I'm using the right terminology or if > anything I'm saying makes sense, but I recall something similar with > OpenSSH being clever enough to write things out not to stdout but to the > screen). You can read directly from the terminal by opening "/dev/tty". > Darcs on the other hand is not so clever, and we (incidentally) exploit > that stupidity to script our interactive testing (echo yn | darcs foo). > > Hmm, not sure what to do about this, so I'm replying to the list in the > hope that somebody will pipe up with a nice, elegant solution that will > just fix everything. This seems like something Haskeline could conceivably do; namely, when stdin isn't a terminal, read from /dev/tty instead of stdin. However, usually we really do want to read from stdin; a couple examples are testing (as you mentioned) and running in the emacs shell. The current rules are listed at: http://hackage.haskell.org/packages/archive/haskeline/0.6.2.1/doc/html/System-Console-Haskeline.html#3 In particular, if you do "cat | darcs" then haskeline uses stdin/stdout with no rich editing. In contrast, if you do "darcs | cat" then haskeline uses rich editing with stdin for input and /dev/tty for output. The real trick is figuring out what the user wants you to do. I can see two options: 1) Query an environmental flag (e.g. HASKELINE_FORCE_TTY). 2) Add a parameter to one of Haskeline's functions. I'm a little wary of this since it changes the API, and as I said before you can't always automatically detect whether the user wants tty or stdin. Best, -Judah _______________________________________________ darcs-users mailing list [email protected] http://lists.osuosl.org/mailman/listinfo/darcs-users
