Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: PATCH: edit-command-line with spaces in EDITOR



2008/12/16 Clint Adams <clint@xxxxxxx>:
> On Tue, Dec 16, 2008 at 06:07:50PM +0100, Mikael Magnusson wrote:
>> I'm not convinced this is a good idea. If the binary or path to it
>> contains a space, you just broke it. It's probably better to just tell
>> people to make a short wrapper script. Also, if some apps parse spaces
>> in EDITOR and others don't, then you effectively have to _both_ keep
>> the path+binary space-free and not give any arguments. That seems
>> suboptimal. FWIW git interprets spaces in EDITOR but... AFAIK it has
>> always been the name of a binary and nothing more.
>
> Are you aware of any applications which _do not_ split EDITOR on spaces
> or is this all theoretical?

sudo, http://www.google.com/codesearch?hl=en&q=getenv.*EDITOR+show:PzdGoZtAqeI:G9wXYPpcdgc:AfyqUXSwU3U&sa=N&cd=9&ct=rc&cs_p=ftp://ftp.sunfreeware.com/pub/freeware/SOURCES/sudo-1.6.8p9.tar.gz&cs_f=sudo-1.6.8p9/visudo.c

tla, http://www.google.com/codesearch?hl=en&q=getenv.*EDITOR+show:6rdpA64V62I:9dG97f3kZF0:vHcDzWcDvPI&sa=N&cd=11&ct=rc&cs_p=http://freshmeat.net/redir/archrevctl/41124/url_tgz/tla-1.3.5.tar.gz&cs_f=tla-1.3.5/src/tla/libarch/editor.c

(at this point i would like to note there are a sad number of programs
that do sprintf(cmd, "%s '%s'", editor, file); system(cmd);)

ironically emacs,
% ALTERNATE_EDITOR="ls" emacsclient =emacs
emacsclient: can't find socket; have you started the server?
To start the server in Emacs, type "M-x server-start".
/usr/bin/emacs
% ALTERNATE_EDITOR="ls -l" emacsclient =emacs
emacsclient: can't find socket; have you started the server?
To start the server in Emacs, type "M-x server-start".
emacsclient: error executing alternate editor "ls -l"

So far, i have only found lots of strange code and programs that do
not split EDITOR, I have yet to find one that does (except for git
which i already knew about). To be fair, some of the "strange code"
does split it, but they also split filenames and run arbitrary code so
I don't think those count.

pam_unix in osx (i think?),
http://www.google.com/codesearch?hl=en&q=getenv.*EDITOR+show:uJDRNZUL70A:waEx2HuwGy4:ADkvXgRqXEk&sa=N&cd=107&ct=rc&cs_p=http://www.opensource.apple.com/darwinsource/tarballs/other/pam_modules-13.tar.gz&cs_f=pam_modules-13/pam_unix/pw_util.c

crontab in ditto,
http://www.google.com/codesearch?hl=en&q=getenv.*EDITOR+show:_00kONdzoCk:TrU12ZEvJTg:zznBZOnQrgA&sa=N&cd=111&ct=rc&cs_p=http://www.opensource.apple.com/darwinsource/tarballs/other/cron-12.2.tar.gz&cs_f=cron-12.2/crontab/crontab.c

here's one that purposely calls system() to split on spaces in EDITOR,
http://www.google.com/codesearch?hl=en&q=getenv.*EDITOR+show:X1tmsVlC7-g:7ffgu2ZLT7E:8ZS2TlXP2Xs&sa=N&cd=120&ct=rc&cs_p=ftp://153.19.33.250/software/shadow/shadow-4.0.18.1.tar.bz2&cs_f=shadow-4.0.18.1/src/vipw.c

-- 
Mikael Magnusson



Messages sorted by: Reverse Date, Date, Thread, Author