David Roundy <[EMAIL PROTECTED]> writes:
> On Sun, Jan 28, 2007 at 03:19:56PM -0800, David Roundy wrote:
>> Incidentally (unrelated to this email), darcs has recently started opening
>> my emacs without the file open that I want to edit (so I have to find it
>> with "ls -tr"). Not sure what's triggered this, and I don't have time to
>> look into it, but hopefully if you all keep an eye out for it, someone will
>> track it down and fix it.
>
> In spite of the fact that I need to prepare for class tomorrow, I tracked
> this down a bit, and my DARCS_EDITOR is:
>
> DARCS_EDITOR=emacs --eval "(setq make-backup-files nil)"
>
> And the problem is that darcs is doing some crazy stuff in breakCommand, in
> particular using words to split up the arguments, which of course breaks up
> the lisp statement and makes everything go crazy. I recognize this as one
> of the "waiting for resubmission" patches, which I see is a pretty tricky
> one. Ideally, we'd let the user's shell do the splitting by running a
> program such as:
>
> breakCommand x = do system ("test_args "++x ++ " > foo")
> args <- lines0 `fmap` readFile foo
> where lines0 "" = []
> lines0 s = let (l, s') = break (== '\0') s
> in l : case s' of
> [] -> []
> (_:s'') -> lines0 s''
>
> test_args.hs:
> main = do args <- getArgs
> mapM_ putStr0 args
> where putStr0 x = do { putStr x; putChar '\0'; }
>
> This is obviously a horribly clumsy way to trick the shell into expanding
> our arguments for us, but something that is "equivalently good" would be
> nice. In particular, I'd rather not have to define a "darcs" way of
> escaping strings, and instead use whatever is native to whatever OS the
> user is using.
I agree, supporting the escaping convention of the shell is what the user
expects because that's how it's handled in other tools (eg mutt and svn
use system+filename quoting).
Just for the record, here are the problems with the previous versions
used in darcs:
1. system without escaping the filename: big security risk if we take
arguments from untrusted sources, doesn't handle paths with spaces
supplied by darcs
2. exec_interactive without breaking up the user command: doesn't handle
DARCS_EDITOR="emacs -nw" since there is no file called "emacs -nw" in
the PATH
3. exec_interactive with breakCommand: doesn't handle spaces in paths
in the command path, doesn't handle quoting
Another possibility would be going back to using system and let the shell
handle escaping filenames like:
edit_file f = do
ed <- get_editor
setEnv "DARCS_ARGUMENT" f
system (ed ++ " \"$DARCS+ARGUMENT\"")
Anyone knows if one of these would work on windows?
Benedikt
_______________________________________________
darcs-devel mailing list
[email protected]
http://www.abridgegame.org/cgi-bin/mailman/listinfo/darcs-devel