GNU bug report logs -
#16005
inferior-lisp and filenames with spaces
Previous Next
Reported by: Steven Litvintchouk <sdlitvin <at> earthlink.net>
Date: Fri, 29 Nov 2013 23:20:02 UTC
Severity: minor
Tags: moreinfo
Found in version 24.3
Fixed in version 28.1
Done: Lars Ingebrigtsen <larsi <at> gnus.org>
Bug is archived. No further changes may be made.
To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 16005 in the body.
You can then email your comments to 16005 AT debbugs.gnu.org in the normal way.
Toggle the display of automated, internal messages from the tracker.
Report forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#16005
; Package
emacs
.
(Fri, 29 Nov 2013 23:20:02 GMT)
Full text and
rfc822 format available.
Acknowledgement sent
to
Steven Litvintchouk <sdlitvin <at> earthlink.net>
:
New bug report received and forwarded. Copy sent to
bug-gnu-emacs <at> gnu.org
.
(Fri, 29 Nov 2013 23:20:02 GMT)
Full text and
rfc822 format available.
Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
Trying to run an inferior lisp program on Windows 7,
with the value of inferior-lisp-program set to
"D:/More Program Files (x86)/clisp-2.49/clisp.exe",
caused an error with error message:
"Spawning child process: invalid argument"
The reason is that the function inferior-lisp (defined in inf-lisp.el)
calls the function split-string, whose arg SEPARATORS defaults to "[
\f\t\n\r\v]+".
But Microsoft Windows allows spaces in filenames (as in the
inferior-lisp-program filename given above).
I patched this to check if we're on Windows-nt, and if so, to call
split-string with SEPARATORS bound to "[\f\t\n\r\v]+". (no space)
(defun inferior-lisp (cmd)
"Run an inferior Lisp process, input and output via buffer
`*inferior-lisp*'.
If there is a process already running in `*inferior-lisp*', just switch
to that buffer.
With argument, allows you to edit the command line (default is value
of `inferior-lisp-program'). Runs the hooks from
`inferior-lisp-mode-hook' (after the `comint-mode-hook' is run).
\(Type \\[describe-mode] in the process buffer for a list of commands.)"
(interactive (list (if current-prefix-arg
(read-string "Run lisp: " inferior-lisp-program)
inferior-lisp-program)))
(if (not (comint-check-proc "*inferior-lisp*"))
(let ((cmdlist (if (equal system-type 'windows-nt)
(split-string cmd "[\f\t\n\r\v]+") ; SDL: Windows allows
spaces in filenames
(split-string cmd)
)))
(set-buffer (apply (function make-comint)
"inferior-lisp" (car cmdlist) nil (cdr cmdlist)))
(inferior-lisp-mode)))
(setq inferior-lisp-buffer "*inferior-lisp*")
(pop-to-buffer-same-window "*inferior-lisp*"))
In GNU Emacs 24.3.1 (i386-mingw-nt6.1.7601)
of 2013-03-17 on MARVIN
Windowing system distributor `Microsoft Corp.', version 6.1.7601
Configured using:
`configure --with-gcc (4.7) --cflags
-ID:/devel/emacs/libs/libXpm-3.5.8/include
-ID:/devel/emacs/libs/libXpm-3.5.8/src
-ID:/devel/emacs/libs/libpng-dev_1.4.3-1/include
-ID:/devel/emacs/libs/zlib-dev_1.2.5-2/include
-ID:/devel/emacs/libs/giflib-4.1.4-1/include
-ID:/devel/emacs/libs/jpeg-6b-4/include
-ID:/devel/emacs/libs/tiff-3.8.2-1/include
-ID:/devel/emacs/libs/gnutls-3.0.9/include
-ID:/devel/emacs/libs/libiconv-1.13.1-1-dev/include
-ID:/devel/emacs/libs/libxml2-2.7.8/include/libxml2'
Important settings:
value of $LANG: ENU
locale-coding-system: cp1252
default enable-multibyte-characters: t
Major mode: Info
Minor modes in effect:
tooltip-mode: t
mouse-wheel-mode: t
tool-bar-mode: t
menu-bar-mode: t
file-name-shadow-mode: t
global-font-lock-mode: t
font-lock-mode: t
blink-cursor-mode: t
auto-composition-mode: t
auto-encryption-mode: t
auto-compression-mode: t
buffer-read-only: t
line-number-mode: t
transient-mark-mode: t
Recent input:
<help-echo> <help-echo> <help-echo> <help-echo> C-x
o C-x b i n f - l i s SPC - w i n SPC p a SPC SPC <return>
<down-mouse-1> <mouse-1> i f SPC ( e q u a l SPC s
y s t e m - t y p e SPC " w i n d o w s - n t " <return>
<tab> C-e C-p ) C-n C-a <tab> C-e C-b C-b C-j <tab>
C-p C-f C-f C-f C-b ( C-a <tab> C-n C-a <tab> C-p C-e
C-j ( s p l i t - s t r i n g SPC c m d ) <down-mouse-1>
<mouse-1> <down-mouse-1> <mouse-1> <escape> ; SPC W
i n d o w s SPC a l l o w s SPC b l a n k s SPC i n
SPC f i l e n a m e s <left> <left> <left> <left> <left>
<left> <left> <left> <left> <left> <left> <left> <left>
<left> <backspace> <backspace> <backspace> <backspace>
<backspace> s p a c e C-x s y y <help-echo> <help-echo>
<help-echo> <down-mouse-1> <mouse-1> C-h ? <help-echo>
<mouse-1> <mouse-1> <mouse-1> <mouse-1> <mouse-1> <mouse-1>
<mouse-1> <mouse-1> <mouse-1> <mouse-1> <mouse-1> <mouse-1>
<mouse-1> <mouse-1> <mouse-1> <mouse-1> <mouse-1> <mouse-1>
<mouse-1> <mouse-1> <mouse-1> <mouse-1> <mouse-1> <mouse-1>
<mouse-1> <mouse-1> <mouse-1> <mouse-1> <mouse-1> <mouse-1>
<mouse-1> C-p <mouse-1> <down-mouse-1> <mouse-1> <mouse-1>
<mouse-1> <mouse-1> <mouse-1> <mouse-1> <mouse-1> <mouse-1>
<mouse-1> <mouse-1> <mouse-1> <help-echo> <down-mouse-1>
<mouse-1> C-x 1 C-h i m e m a c s <return> SPC SPC
<help-echo> <down-mouse-1> <mouse-2> <help-echo> <help-echo>
<down-mouse-1> <mouse-2> <mouse-1> <help-echo> <help-echo>
<help-echo> <tool-bar> <Back in history> <help-echo>
<help-echo> <help-echo> <help-echo> <help-echo> <down-mouse-1>
<mouse-2> <escape> x r e p o e r <backspace> <backspace>
r t - = e <backspace> <backspace> e m a c s = b i g
<backspace> <backspace> <backspace> <backspace> - b
u g <return>
Recent messages:
Quit
Making completion list...
Type C-x 1 to delete the help window.
Saving file d:/More Program
Files/Shareware/emacs-24.3/lisp/progmodes/inf-lisp-windows-patch.el...
Wrote d:/More Program
Files/Shareware/emacs-24.3/lisp/progmodes/inf-lisp-windows-patch.el
Saving file d:/More Program
Files/Shareware/emacs-24.3/lisp/progmodes/inf-lisp.el...
Wrote d:/More Program Files/Shareware/emacs-24.3/lisp/progmodes/inf-lisp.el
View mode: type C-h for help, h for commands, q to quit.
Composing main Info directory...done
Load-path shadows:
None found.
Features:
(shadow sort mail-extr emacsbug message format-spec rfc822 mml mml-sec
mm-decode mm-bodies mm-encode mail-parse rfc2231 mailabbrev gmm-utils
mailheader sendmail rfc2047 rfc2045 ietf-drums info goto-addr thingatpt
noutline outline easy-mmode view mule-util debug apropos pp find-func
help-mode easymenu help-fns misearch multi-isearch dired-aux dired
inf-lisp comint ansi-color ring gnus gnus-ems nnheader gnus-util
mail-utils mm-util mail-prsvr wid-edit cus-start cus-load time-date
tooltip ediff-hook vc-hooks lisp-float-type mwheel dos-w32 ls-lisp
w32-common-fns disp-table w32-win w32-vars tool-bar dnd fontset image
regexp-opt fringe tabulated-list newcomment lisp-mode register page
menu-bar rfn-eshadow timer select scroll-bar mouse jit-lock font-lock
syntax facemenu font-core frame cham georgian utf-8-lang misc-lang
vietnamese tibetan thai tai-viet lao korean japanese hebrew greek
romanian slovak czech european ethiopic indian cyrillic chinese
case-table epa-hook jka-cmpr-hook help simple abbrev minibuffer loaddefs
button faces cus-face macroexp files text-properties overlay sha1 md5
base64 format env code-pages mule custom widget hashtable-print-readable
backquote make-network-process w32 multi-tty emacs)
[Message part 2 (text/html, inline)]
[C:\Users\Steven\My Templates\Thunderbird\yellow-spine.gif (image/gif, inline)]
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#16005
; Package
emacs
.
(Sat, 30 Nov 2013 22:13:01 GMT)
Full text and
rfc822 format available.
Message #8 received at 16005 <at> debbugs.gnu.org (full text, mbox):
Steven Litvintchouk wrote:
> But Microsoft Windows allows spaces in filenames
I think every platform that Emacs supports allows spaces in filenames;
just that people on non-MS Windows platforms generally know to avoid
such filenames. ;)
> I patched this to check if we're on Windows-nt, and if so, to call
> split-string with SEPARATORS bound to "[\f\t\n\r\v]+"
That doesn't work, consider eg
/bin/lisp --some-arg
versus
/Program Files/lisp
Changed bug title to 'inferior-lisp and filenames with spaces' from '24.3; function inferior-lisp needs patch to work with certain filenames in Windows-NT'
Request was from
Glenn Morris <rgm <at> gnu.org>
to
control <at> debbugs.gnu.org
.
(Sat, 30 Nov 2013 22:19:02 GMT)
Full text and
rfc822 format available.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#16005
; Package
emacs
.
(Thu, 15 Jul 2021 05:34:01 GMT)
Full text and
rfc822 format available.
Message #13 received at 16005 <at> debbugs.gnu.org (full text, mbox):
Steven Litvintchouk <sdlitvin <at> earthlink.net> writes:
> Trying to run an inferior lisp program on Windows 7,
> with the value of inferior-lisp-program set to
> "D:/More Program Files (x86)/clisp-2.49/clisp.exe",
>
> caused an error with error message:
> "Spawning child process: invalid argument"
>
> The reason is that the function inferior-lisp (defined in inf-lisp.el)
> calls the function split-string, whose arg SEPARATORS defaults to "[ \f\t\n\r\v]+".
This problem is still present in Emacs 28:
(interactive (list (if current-prefix-arg
(read-string "Run lisp: " inferior-lisp-program)
inferior-lisp-program)))
(if (not (comint-check-proc "*inferior-lisp*"))
(let ((cmdlist (split-string cmd)))
(set-buffer (apply (function make-comint)
"inferior-lisp" (car cmdlist) nil (cdr cmdlist)))
(inferior-lisp-mode)))
The only way this could work is that if we either split the prompt into
two parts (one for the command and one for the options), or that we
require that the user quotes the spaces, and then use a splitting
function that's aware of that. So the user would have to type
"D:/More Program Files (x86)/clisp-2.49/clisp.exe" -some -option
or the like.
I thought Emacs had a shell-syntax-aware splitting function (that would
tokenise that into a list of three items), but I can't find it now...
anybody remember what it's called (if we do have it)? I.e.,
(that-func "\"foo bar\" zot") => ("foo bar" "zot")
and
(that-func "foo\\ bar zot") => ("foo bar" "zot")
--
(domestic pets only, the antidote for overdose, milk.)
bloggy blog: http://lars.ingebrigtsen.no
Added tag(s) moreinfo.
Request was from
Lars Ingebrigtsen <larsi <at> gnus.org>
to
control <at> debbugs.gnu.org
.
(Thu, 15 Jul 2021 05:34:01 GMT)
Full text and
rfc822 format available.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#16005
; Package
emacs
.
(Thu, 15 Jul 2021 07:00:02 GMT)
Full text and
rfc822 format available.
Message #18 received at 16005 <at> debbugs.gnu.org (full text, mbox):
> From: Lars Ingebrigtsen <larsi <at> gnus.org>
> Date: Thu, 15 Jul 2021 07:33:33 +0200
> Cc: 16005 <at> debbugs.gnu.org
>
> Steven Litvintchouk <sdlitvin <at> earthlink.net> writes:
>
> > Trying to run an inferior lisp program on Windows 7,
> > with the value of inferior-lisp-program set to
> > "D:/More Program Files (x86)/clisp-2.49/clisp.exe",
> >
> > caused an error with error message:
> > "Spawning child process: invalid argument"
> >
> > The reason is that the function inferior-lisp (defined in inf-lisp.el)
> > calls the function split-string, whose arg SEPARATORS defaults to "[ \f\t\n\r\v]+".
>
> This problem is still present in Emacs 28:
>
> (interactive (list (if current-prefix-arg
> (read-string "Run lisp: " inferior-lisp-program)
> inferior-lisp-program)))
> (if (not (comint-check-proc "*inferior-lisp*"))
> (let ((cmdlist (split-string cmd)))
> (set-buffer (apply (function make-comint)
> "inferior-lisp" (car cmdlist) nil (cdr cmdlist)))
> (inferior-lisp-mode)))
>
> The only way this could work is that if we either split the prompt into
> two parts (one for the command and one for the options), or that we
> require that the user quotes the spaces, and then use a splitting
> function that's aware of that. So the user would have to type
>
> "D:/More Program Files (x86)/clisp-2.49/clisp.exe" -some -option
>
> or the like.
If we prompt the users for a shell command, we should expect the users
to quote it as they would when they type at the shell's prompt. is
this prompt for the complete shell command, or is it only for the name
of the program's executable file? If the latter, we should run the
result through shell-quote-argument before using it; if the former,
the user should do the quoting, and there's no bug in Emacs.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#16005
; Package
emacs
.
(Thu, 15 Jul 2021 07:11:02 GMT)
Full text and
rfc822 format available.
Message #21 received at 16005 <at> debbugs.gnu.org (full text, mbox):
Eli Zaretskii <eliz <at> gnu.org> writes:
>> (let ((cmdlist (split-string cmd)))
>> (set-buffer (apply (function make-comint)
>> "inferior-lisp" (car cmdlist) nil (cdr cmdlist)))
[...]
> If we prompt the users for a shell command, we should expect the users
> to quote it as they would when they type at the shell's prompt. is
> this prompt for the complete shell command, or is it only for the name
> of the program's executable file? If the latter, we should run the
> result through shell-quote-argument before using it; if the former,
> the user should do the quoting, and there's no bug in Emacs.
It's the former. The problem is that there is no way for the user to
quote the command, since we do a `split-string' on what they typed in
before executing it.
--
(domestic pets only, the antidote for overdose, milk.)
bloggy blog: http://lars.ingebrigtsen.no
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#16005
; Package
emacs
.
(Thu, 15 Jul 2021 07:26:02 GMT)
Full text and
rfc822 format available.
Message #24 received at 16005 <at> debbugs.gnu.org (full text, mbox):
> From: Lars Ingebrigtsen <larsi <at> gnus.org>
> Cc: sdlitvin <at> earthlink.net, 16005 <at> debbugs.gnu.org
> Date: Thu, 15 Jul 2021 09:10:33 +0200
>
> Eli Zaretskii <eliz <at> gnu.org> writes:
>
> >> (let ((cmdlist (split-string cmd)))
> >> (set-buffer (apply (function make-comint)
> >> "inferior-lisp" (car cmdlist) nil (cdr cmdlist)))
>
> [...]
>
> > If we prompt the users for a shell command, we should expect the users
> > to quote it as they would when they type at the shell's prompt. is
> > this prompt for the complete shell command, or is it only for the name
> > of the program's executable file? If the latter, we should run the
> > result through shell-quote-argument before using it; if the former,
> > the user should do the quoting, and there's no bug in Emacs.
>
> It's the former. The problem is that there is no way for the user to
> quote the command, since we do a `split-string' on what they typed in
> before executing it.
Then how about using split-string-and-unquote instead of split-string?
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#16005
; Package
emacs
.
(Thu, 15 Jul 2021 07:31:01 GMT)
Full text and
rfc822 format available.
Message #27 received at 16005 <at> debbugs.gnu.org (full text, mbox):
Eli Zaretskii <eliz <at> gnu.org> writes:
> Then how about using split-string-and-unquote instead of split-string?
That would be an improvement, certainly. It'd take care of
"\"foo bar\" zot". However, it doesn't do "foo\\ bar zot", and both are
equivalent in shells.
Which is why I wondered whether we had a function to split based on
shell(ish) syntax, which would be the optimal solution here...
--
(domestic pets only, the antidote for overdose, milk.)
bloggy blog: http://lars.ingebrigtsen.no
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#16005
; Package
emacs
.
(Thu, 15 Jul 2021 07:46:02 GMT)
Full text and
rfc822 format available.
Message #30 received at 16005 <at> debbugs.gnu.org (full text, mbox):
> From: Lars Ingebrigtsen <larsi <at> gnus.org>
> Cc: sdlitvin <at> earthlink.net, 16005 <at> debbugs.gnu.org
> Date: Thu, 15 Jul 2021 09:30:34 +0200
>
> Eli Zaretskii <eliz <at> gnu.org> writes:
>
> > Then how about using split-string-and-unquote instead of split-string?
>
> That would be an improvement, certainly. It'd take care of
> "\"foo bar\" zot". However, it doesn't do "foo\\ bar zot", and both are
> equivalent in shells.
Users will have to use quoting "like this". We can document that.
It's a relatively rare use case, so I don't think the partial support
for quoting is such a bad idea.
> Which is why I wondered whether we had a function to split based on
> shell(ish) syntax, which would be the optimal solution here...
I think split-string-and-unquote is the only one that comes close. If
someone wants to emulate the shells we support, patches are welcome
(and then there will still be the problem to know the exact shell
which is being targeted in each use case).
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#16005
; Package
emacs
.
(Thu, 15 Jul 2021 08:01:01 GMT)
Full text and
rfc822 format available.
Message #33 received at 16005 <at> debbugs.gnu.org (full text, mbox):
Eli Zaretskii <eliz <at> gnu.org> writes:
>> Which is why I wondered whether we had a function to split based on
>> shell(ish) syntax, which would be the optimal solution here...
>
> I think split-string-and-unquote is the only one that comes close. If
> someone wants to emulate the shells we support, patches are welcome
> (and then there will still be the problem to know the exact shell
> which is being targeted in each use case).
That's true. However, this reminded me that we do have pretty good
completion in `M-!', so I thought we must have some tokenisation support
somewhere, and indeed: `shell--parse-pcomplete-arguments' seems to fit
the bill here. So adding a `shell-split-string' by wrapping that
function seems like it should be possible. I'll poke some more at it;
it doesn't quite seem to handle \ as expected in all circumstances.
It handles "" and '' fine, as far as I can tell:
'foo"bar' zot
-> (("foo\"bar" "zot") 1 11)
--
(domestic pets only, the antidote for overdose, milk.)
bloggy blog: http://lars.ingebrigtsen.no
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#16005
; Package
emacs
.
(Thu, 15 Jul 2021 08:21:01 GMT)
Full text and
rfc822 format available.
Message #36 received at 16005 <at> debbugs.gnu.org (full text, mbox):
> From: Lars Ingebrigtsen <larsi <at> gnus.org>
> Cc: sdlitvin <at> earthlink.net, 16005 <at> debbugs.gnu.org
> Date: Thu, 15 Jul 2021 10:00:23 +0200
>
> That's true. However, this reminded me that we do have pretty good
> completion in `M-!', so I thought we must have some tokenisation support
> somewhere, and indeed: `shell--parse-pcomplete-arguments' seems to fit
> the bill here. So adding a `shell-split-string' by wrapping that
> function seems like it should be possible. I'll poke some more at it;
> it doesn't quite seem to handle \ as expected in all circumstances.
If that works, I'd suggest to call the function something that begins
with split-string-, like split-string-shell-command or somesuch. I
think this would make its discovery easier.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#16005
; Package
emacs
.
(Thu, 15 Jul 2021 08:31:01 GMT)
Full text and
rfc822 format available.
Message #39 received at 16005 <at> debbugs.gnu.org (full text, mbox):
Eli Zaretskii <eliz <at> gnu.org> writes:
> If that works,
It did -- I just had to wrap it in a binding for the shell escaped.
> I'd suggest to call the function something that begins
> with split-string-, like split-string-shell-command or somesuch. I
> think this would make its discovery easier.
Good point. I've now renamed it.
So back to the original bug report -- I'll change it to use the new
splitting function, and then document that it's doing so.
--
(domestic pets only, the antidote for overdose, milk.)
bloggy blog: http://lars.ingebrigtsen.no
bug marked as fixed in version 28.1, send any further explanations to
16005 <at> debbugs.gnu.org and Steven Litvintchouk <sdlitvin <at> earthlink.net>
Request was from
Lars Ingebrigtsen <larsi <at> gnus.org>
to
control <at> debbugs.gnu.org
.
(Thu, 15 Jul 2021 08:34:02 GMT)
Full text and
rfc822 format available.
bug archived.
Request was from
Debbugs Internal Request <help-debbugs <at> gnu.org>
to
internal_control <at> debbugs.gnu.org
.
(Thu, 12 Aug 2021 11:24:04 GMT)
Full text and
rfc822 format available.
This bug report was last modified 2 years and 255 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.