On Fri, Feb 02, 2007 at 01:23:54 +0100, Benedikt Schmidt wrote: > This one breaks when arg contains spaces or other special shell syntax > like backquotes (cmd++" "++"darcs`rm -rf ..`/logfile").
Accepting these (and I think I even understand why) Eric makes sure he understands ------------------------------ Please shout if I've gotten it wrong! Say we set DARCS_EDITOR to something like fancyEdit moo "some `crazy thing`" My question was why we should set the environment to: moo "some `crazy thing`" and then call /bin/sh -c fancyEdit "$DARCS_ARGUMENT" When we could instead just call it directly /bin/sh -c fancyEdit moo "some `crazy thing`" The answer is, as Benedikt says, that we don't want the shell to intrepret the arguments, for example `crazy thing`, so we protect it by writing them as a string in the environment variable $DARCS_ARGUMENT. When sh sees the whole command (fancyEdit "$DARCS_ARGUMENT"), the shell expands that into (fancyEdit moo "some `crazy thing`") and that's *it*. Nothing more. The editor gets $0 - fancyEdit $1 - moo $2 - "some `crazy thing`" It's now up to the editor to figure out what moo and "some `crazy thing`" mean. Quotes might have nothing to do with quoting, nor backquotes to do with running commmands. For example, you might just want to insert ``some TeX''. > A little history what darcs used for starting EDITOR: [snip] > Patch names: > [1] * quote filename passed to $EDITOR > [2] * add exec_interactive and use it instead of system in some places > [3] * fix [issue370], darcs ignored args contained in VISUAL variable Hey, thanks for that. Saves me a lot of hunting down. -- Eric Kow http://www.loria.fr/~kow PGP Key ID: 08AC04F9 Merci de corriger mon français.
pgpEsQxqRsAww.pgp
Description: PGP signature
_______________________________________________ darcs-devel mailing list [email protected] http://www.abridgegame.org/cgi-bin/mailman/listinfo/darcs-devel
