all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: "Drew Adams" <drew.adams@oracle.com>
To: <2536@emacsbugs.donarmstrong.com>,
	"'Andreas Schwab'" <schwab@linux-m68k.org>
Subject: bug#2536: 23.0.90; ! in Dired does not shell-quote the command name and args
Date: Fri, 6 Mar 2009 14:09:36 -0800	[thread overview]
Message-ID: <008b01c99ea8$3cac7800$0200a8c0@us.oracle.com> (raw)
In-Reply-To: <007601c99b49$ad4fb610$0200a8c0@us.oracle.com>

> From: Drew Adams Sent: Monday, March 02, 2009 7:15 AM
> > > In sum, I don't have any insight about what fix is needed, 
> > > but there is definitely a problem, at least for MS Windows,
> > > where spaces in file names are common.
> > 
> > If you want to use shell meta characters on the command line 
> > it is your own responsibility to add proper quoting.
> > Note that file name completion
> > (ie. minibuffer-complete-shell-command) will DTRT here.
> 
> Yes, I realized after I sent the report that there is no way 
> for Emacs to distinguish a file name with spaces from separate
> arguments. You can close this bug, I guess.

Actually, no, file name completion does *not* DTRT here.
Similarly, for `&' and `M-!'.

c:/Prog TAB will correctly complete to c:/Program Files/ - yes.
But c:/Program Files/ad TAB will *not* complete to
c:/Program Files/Adobe/, and so on.

You cannot use completion to get the shell command (program)
c:/Program Files/Adobe/Framemaker7.2/FrameMaker.exe.  And you
cannot even complete c:/Program  (with a trailing space) to
c:/Program Files/.  The shell thinks the executable is just
c:/Program, and it tries to complete local file names as
shell arguments to pass to that program.

And anyway, if you could complete to the executable
c:/Program Files/Adobe/Framemaker7.2/FrameMaker.exe, then bash
would just complain that there is no such file: c:/Program,
just as it does if you type all of that in and hit RET.

Again, I'm not sure what the ideal solution is. It's true that there is no way
to automatically tell in all cases whether a space separates arguments or is
part of a file name. 

But the existing file-name completion is in any case a bit brain-dead. 

It knows that c:/Prog completes to c:/Program Files/, but it doesn't know to
complete c:/Program Files/ad to c:/Program Files/Adobe.  And in such a case
there is *no ambiguity* over embedded spaces vs argument separators.  There's
nothing tricky happening here, in theory.

The problem is that during completion of c:/Prog Emacs knows that this is a file
name with a space, but as soon as you type ad TAB, it forgets that previous
knowledge and thinks you are trying to complete an argument Files/ad, to be
passed to command c:/Program.  Silly.

The file-name completion could be made more robust. The only potential problem
occurs when there is true ambiguity between an existing file name, with spaces,
and an existing file name whose name is a prefix up to a space.  For example, if
both a directory c:/Program Files/ and an executable c:/Program exist, then it's
not clear whether the space after c:/Program is embedded in a file name or
separates the command name from an argument.

If priority were always given to the longer prefix in such a case, then `!',
`&', and `M-!' would be much more usable. Then, Emacs would not try to look at
Files/ad as a potential argument.

In the uncommon case of true ambiguity (e.g. both dir c:/Program Files/ and
executable c:/Program), a user could anyway manually add quote marks as needed -
as s?he *must* do now in all cases where there are spaces in file names.









      reply	other threads:[~2009-03-06 22:09 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-03-02  5:36 bug#2536: 23.0.90; ! in Dired does not shell-quote the command name and args Drew Adams
2009-03-02  6:18 ` Drew Adams
2009-03-02  9:23   ` Andreas Schwab
2009-03-02 15:15     ` Drew Adams
2009-03-06 22:09       ` Drew Adams [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='008b01c99ea8$3cac7800$0200a8c0@us.oracle.com' \
    --to=drew.adams@oracle.com \
    --cc=2536@emacsbugs.donarmstrong.com \
    --cc=schwab@linux-m68k.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.