unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#10458: 24.0.92; ! in dired on a file starting with a hyphen
@ 2012-01-08 20:05 Michael Heerdegen
  2012-01-09  1:30 ` Stefan Monnier
  2022-03-28  3:02 ` Drew Adams
  0 siblings, 2 replies; 27+ messages in thread
From: Michael Heerdegen @ 2012-01-08 20:05 UTC (permalink / raw)
  To: 10458

Hello,

Please see #2536 for a similar issue.

I'm working with Gnu/Linux.  If I hit ! in dired on a file starting with
"-", the hyphen is not quoted so that the specified program will
interpret the file name as an option.  I guess this is nearly never
what the user wants.


In GNU Emacs 24.0.92.1 (i486-pc-linux-gnu, GTK+ Version 3.2.3)
 of 2012-01-05 on zelenka, modified by Debian
 (emacs-snapshot package, version 1:20120105-1)
Windowing system distributor `The X.Org Foundation', version 11.0.11102902
configured using `configure  '--build' 'i486-linux-gnu' '--host' 'i486-linux-gnu' '--prefix=/usr' '--sharedstatedir=/var/lib' '--libexecdir=/usr/lib' '--localstatedir=/var' '--infodir=/usr/share/info' '--mandir=/usr/share/man' '--with-pop=yes' '--enable-locallisppath=/etc/emacs-snapshot:/etc/emacs:/usr/local/share/emacs/24.0.92/site-lisp:/usr/local/share/emacs/site-lisp:/usr/share/emacs/24.0.92/site-lisp:/usr/share/emacs/site-lisp' '--without-compress-info' '--with-crt-dir=/usr/lib/i386-linux-gnu/' '--with-x=yes' '--with-x-toolkit=gtk3' '--with-imagemagick=yes' 'build_alias=i486-linux-gnu' 'host_alias=i486-linux-gnu' 'CFLAGS=-DDEBIAN -DSITELOAD_PURESIZE_EXTRA=5000 -g -O2''

Important settings:
  value of $LC_ALL: de_DE.utf8
  value of $LC_COLLATE: nil
  value of $LC_CTYPE: nil
  value of $LC_MESSAGES: nil
  value of $LC_MONETARY: nil
  value of $LC_NUMERIC: nil
  value of $LC_TIME: C
  value of $LANG: de_DE.utf8
  value of $XMODIFIERS: nil
  locale-coding-system: utf-8-unix
  default enable-multibyte-characters: t






^ permalink raw reply	[flat|nested] 27+ messages in thread

* bug#10458: 24.0.92; ! in dired on a file starting with a hyphen
  2012-01-08 20:05 bug#10458: 24.0.92; ! in dired on a file starting with a hyphen Michael Heerdegen
@ 2012-01-09  1:30 ` Stefan Monnier
  2012-01-09 17:27   ` Glenn Morris
  2022-02-20 13:50   ` Lars Ingebrigtsen
  2022-03-28  3:02 ` Drew Adams
  1 sibling, 2 replies; 27+ messages in thread
From: Stefan Monnier @ 2012-01-09  1:30 UTC (permalink / raw)
  To: michael_heerdegen; +Cc: 10458

> I'm working with Gnu/Linux.  If I hit ! in dired on a file starting with
> "-", the hyphen is not quoted so that the specified program will
> interpret the file name as an option.  I guess this is nearly never
> what the user wants.

Indeed.  Quoting the file name by doing something like:

    foobar '-toto' titi

won't help (`foobar' won't see the quoting anyway because the shell
will strip it away before passing the result to `foobar').
But we could do something like:

   foobar ./-toto titi

which would not suffer from this problem.


        Stefan





^ permalink raw reply	[flat|nested] 27+ messages in thread

* bug#10458: 24.0.92; ! in dired on a file starting with a hyphen
  2012-01-09  1:30 ` Stefan Monnier
@ 2012-01-09 17:27   ` Glenn Morris
  2012-01-09 19:39     ` Eli Zaretskii
  2012-01-09 22:40     ` Stefan Monnier
  2022-02-20 13:50   ` Lars Ingebrigtsen
  1 sibling, 2 replies; 27+ messages in thread
From: Glenn Morris @ 2012-01-09 17:27 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: michael_heerdegen, 10458

Stefan Monnier wrote:

> But we could do something like:
>
>    foobar ./-toto titi

Or stick a "--" after the command (is that a universal convention?). if
the user did not supply one. This is also what anyone could use to work
around the problem in the meantime.





^ permalink raw reply	[flat|nested] 27+ messages in thread

* bug#10458: 24.0.92; ! in dired on a file starting with a hyphen
  2012-01-09 17:27   ` Glenn Morris
@ 2012-01-09 19:39     ` Eli Zaretskii
  2012-01-10  0:40       ` Richard Stallman
  2012-01-09 22:40     ` Stefan Monnier
  1 sibling, 1 reply; 27+ messages in thread
From: Eli Zaretskii @ 2012-01-09 19:39 UTC (permalink / raw)
  To: Glenn Morris; +Cc: michael_heerdegen, 10458

> From: Glenn Morris <rgm@gnu.org>
> Date: Mon, 09 Jan 2012 12:27:30 -0500
> Cc: michael_heerdegen@web.de, 10458@debbugs.gnu.org
> 
> Stefan Monnier wrote:
> 
> > But we could do something like:
> >
> >    foobar ./-toto titi
> 
> Or stick a "--" after the command (is that a universal convention?).

AFAIK, -- is supported only by GNU getopt (and maybe compatibles).  I
think there's no guarantee that an arbitrary program will support it.





^ permalink raw reply	[flat|nested] 27+ messages in thread

* bug#10458: 24.0.92; ! in dired on a file starting with a hyphen
  2012-01-09 17:27   ` Glenn Morris
  2012-01-09 19:39     ` Eli Zaretskii
@ 2012-01-09 22:40     ` Stefan Monnier
  2012-01-10  7:04       ` Jan D.
  2012-01-10  9:02       ` Glenn Morris
  1 sibling, 2 replies; 27+ messages in thread
From: Stefan Monnier @ 2012-01-09 22:40 UTC (permalink / raw)
  To: Glenn Morris; +Cc: michael_heerdegen, 10458

>> But we could do something like:
>> foobar ./-toto titi
> Or stick a "--" after the command (is that a universal convention?)

not only I don't think it's a universal convention, but I can't think of
any easy reliable way to do that.  E.g. compare

    gcc -o foo -toto.c
vs
    gcc -c foo.c -toto.c


-- Stefan





^ permalink raw reply	[flat|nested] 27+ messages in thread

* bug#10458: 24.0.92; ! in dired on a file starting with a hyphen
  2012-01-09 19:39     ` Eli Zaretskii
@ 2012-01-10  0:40       ` Richard Stallman
  0 siblings, 0 replies; 27+ messages in thread
From: Richard Stallman @ 2012-01-10  0:40 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: michael_heerdegen, 10458

    AFAIK, -- is supported only by GNU getopt (and maybe compatibles).  I
    think there's no guarantee that an arbitrary program will support it.

If you encounter a program that doesn't use GNU getopt
or equivalent, please suggest adopting that feature.
It would be convenient for users if all programs supported it.

-- 
Dr Richard Stallman
President, Free Software Foundation
51 Franklin St
Boston MA 02110
USA
www.fsf.org  www.gnu.org
Skype: No way! That's nonfree (freedom-denying) software.
  Use free telephony http://directory.fsf.org/category/tel/





^ permalink raw reply	[flat|nested] 27+ messages in thread

* bug#10458: 24.0.92; ! in dired on a file starting with a hyphen
  2012-01-09 22:40     ` Stefan Monnier
@ 2012-01-10  7:04       ` Jan D.
  2012-01-10  9:02       ` Glenn Morris
  1 sibling, 0 replies; 27+ messages in thread
From: Jan D. @ 2012-01-10  7:04 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: michael_heerdegen, 10458

Stefan Monnier skrev 2012-01-09 23:40:
>>> But we could do something like:
>>> foobar ./-toto titi
>> Or stick a "--" after the command (is that a universal convention?)
>
> not only I don't think it's a universal convention, but I can't think of
> any easy reliable way to do that.  E.g. compare
>
>      gcc -o foo -toto.c
> vs
>      gcc -c foo.c -toto.c
>

It is universal in that it is in POSIX 1003.1.

	Jan D.







^ permalink raw reply	[flat|nested] 27+ messages in thread

* bug#10458: 24.0.92; ! in dired on a file starting with a hyphen
  2012-01-09 22:40     ` Stefan Monnier
  2012-01-10  7:04       ` Jan D.
@ 2012-01-10  9:02       ` Glenn Morris
  2012-01-10 14:23         ` Stefan Monnier
  1 sibling, 1 reply; 27+ messages in thread
From: Glenn Morris @ 2012-01-10  9:02 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: michael_heerdegen, 10458

Stefan Monnier wrote:

> not only I don't think it's a universal convention, but I can't think of
> any easy reliable way to do that.  E.g. compare
>
>     gcc -o foo -toto.c
> vs
>     gcc -c foo.c -toto.c

Then perhaps it is academic, but I see no ambiguity, since dired keeps
command and file(s) to operate on separate:

  ! gcc -o foo RET
  ! gcc -c RET

It's not like we have to try and decode an entire arbitrary command
string.





^ permalink raw reply	[flat|nested] 27+ messages in thread

* bug#10458: 24.0.92; ! in dired on a file starting with a hyphen
  2012-01-10  9:02       ` Glenn Morris
@ 2012-01-10 14:23         ` Stefan Monnier
  2012-01-10 17:11           ` Glenn Morris
  0 siblings, 1 reply; 27+ messages in thread
From: Stefan Monnier @ 2012-01-10 14:23 UTC (permalink / raw)
  To: Glenn Morris; +Cc: michael_heerdegen, 10458

> Then perhaps it is academic, but I see no ambiguity, since dired keeps
> command and file(s) to operate on separate:

>   ! gcc -o foo RET
>   ! gcc -c RET

How 'bout "! diff -u oldfoo RET"?


        Stefan





^ permalink raw reply	[flat|nested] 27+ messages in thread

* bug#10458: 24.0.92; ! in dired on a file starting with a hyphen
  2012-01-10 14:23         ` Stefan Monnier
@ 2012-01-10 17:11           ` Glenn Morris
  2012-01-10 17:18             ` Glenn Morris
  0 siblings, 1 reply; 27+ messages in thread
From: Glenn Morris @ 2012-01-10 17:11 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: michael_heerdegen, 10458

Stefan Monnier wrote:

> How 'bout "! diff -u oldfoo RET"?

<shakes fist>





^ permalink raw reply	[flat|nested] 27+ messages in thread

* bug#10458: 24.0.92; ! in dired on a file starting with a hyphen
  2012-01-10 17:11           ` Glenn Morris
@ 2012-01-10 17:18             ` Glenn Morris
  2012-01-10 20:03               ` Stefan Monnier
  0 siblings, 1 reply; 27+ messages in thread
From: Glenn Morris @ 2012-01-10 17:18 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: michael_heerdegen, 10458


> Stefan Monnier wrote:
>
>> How 'bout "! diff -u oldfoo RET"?

Actually, GNU diff accepts this just fine:

  diff -u oldfoo -- -newfoo





^ permalink raw reply	[flat|nested] 27+ messages in thread

* bug#10458: 24.0.92; ! in dired on a file starting with a hyphen
  2012-01-10 17:18             ` Glenn Morris
@ 2012-01-10 20:03               ` Stefan Monnier
  2012-01-10 21:45                 ` Jan Djärv
  0 siblings, 1 reply; 27+ messages in thread
From: Stefan Monnier @ 2012-01-10 20:03 UTC (permalink / raw)
  To: Glenn Morris; +Cc: michael_heerdegen, 10458

>>> How 'bout "! diff -u oldfoo RET"?
> Actually, GNU diff accepts this just fine:
>   diff -u oldfoo -- -newfoo

Interesting.  So we need yet another hack in case the file is named
"--".


        Stefan





^ permalink raw reply	[flat|nested] 27+ messages in thread

* bug#10458: 24.0.92; ! in dired on a file starting with a hyphen
  2012-01-10 20:03               ` Stefan Monnier
@ 2012-01-10 21:45                 ` Jan Djärv
  0 siblings, 0 replies; 27+ messages in thread
From: Jan Djärv @ 2012-01-10 21:45 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: michael_heerdegen, 10458


10 jan 2012 kl. 21:03 skrev Stefan Monnier:

>>>> How 'bout "! diff -u oldfoo RET"?
>> Actually, GNU diff accepts this just fine:
>>  diff -u oldfoo -- -newfoo
> 
> Interesting.  So we need yet another hack in case the file is named
> "--".

diff -u oldfoo -- --

should work.

	Jan D.







^ permalink raw reply	[flat|nested] 27+ messages in thread

* bug#10458: 24.0.92; ! in dired on a file starting with a hyphen
  2012-01-09  1:30 ` Stefan Monnier
  2012-01-09 17:27   ` Glenn Morris
@ 2022-02-20 13:50   ` Lars Ingebrigtsen
  2022-02-20 14:07     ` Eli Zaretskii
  2022-02-20 15:14     ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
  1 sibling, 2 replies; 27+ messages in thread
From: Lars Ingebrigtsen @ 2022-02-20 13:50 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: michael_heerdegen, 10458

Stefan Monnier <monnier@IRO.UMontreal.CA> writes:

> Indeed.  Quoting the file name by doing something like:
>
>     foobar '-toto' titi
>
> won't help (`foobar' won't see the quoting anyway because the shell
> will strip it away before passing the result to `foobar').
> But we could do something like:
>
>    foobar ./-toto titi
>
> which would not suffer from this problem.

(I'm going through old bug reports that unfortunately weren't resolved
at the time.)

The discussion then turned to whether "--" was a possibility, and it
isn't.

But adding ./ to file names that start with - should be safe, I think?
So I've now done that in Emacs 29.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no





^ permalink raw reply	[flat|nested] 27+ messages in thread

* bug#10458: 24.0.92; ! in dired on a file starting with a hyphen
  2022-02-20 13:50   ` Lars Ingebrigtsen
@ 2022-02-20 14:07     ` Eli Zaretskii
  2022-02-20 14:10       ` Lars Ingebrigtsen
  2022-02-20 15:14     ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
  1 sibling, 1 reply; 27+ messages in thread
From: Eli Zaretskii @ 2022-02-20 14:07 UTC (permalink / raw)
  To: Lars Ingebrigtsen; +Cc: michael_heerdegen, 10458, monnier

> From: Lars Ingebrigtsen <larsi@gnus.org>
> Date: Sun, 20 Feb 2022 14:50:36 +0100
> Cc: michael_heerdegen@web.de, 10458@debbugs.gnu.org
> 
> But adding ./ to file names that start with - should be safe, I think?

It changes semantics.  The list of file names passed to a command
doesn't necessarily mean "open each file and process it", it could
mean something else, like "make a list of files".  So I don't think we
should do that.





^ permalink raw reply	[flat|nested] 27+ messages in thread

* bug#10458: 24.0.92; ! in dired on a file starting with a hyphen
  2022-02-20 14:07     ` Eli Zaretskii
@ 2022-02-20 14:10       ` Lars Ingebrigtsen
  2022-02-20 14:23         ` Eli Zaretskii
  0 siblings, 1 reply; 27+ messages in thread
From: Lars Ingebrigtsen @ 2022-02-20 14:10 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: michael_heerdegen, 10458, monnier

Eli Zaretskii <eliz@gnu.org> writes:

> It changes semantics.  The list of file names passed to a command
> doesn't necessarily mean "open each file and process it", it could
> mean something else, like "make a list of files".  So I don't think we
> should do that.

Commands like "echo" will behave differently, but I tried to imagine
other functions where this would make a difference, and I failed.  Do
you have any examples?

The old behaviour would misbehave for the vast majority of commands, so
I think it's an improvement.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no





^ permalink raw reply	[flat|nested] 27+ messages in thread

* bug#10458: 24.0.92; ! in dired on a file starting with a hyphen
  2022-02-20 14:10       ` Lars Ingebrigtsen
@ 2022-02-20 14:23         ` Eli Zaretskii
  2022-02-20 14:31           ` Lars Ingebrigtsen
  0 siblings, 1 reply; 27+ messages in thread
From: Eli Zaretskii @ 2022-02-20 14:23 UTC (permalink / raw)
  To: Lars Ingebrigtsen; +Cc: michael_heerdegen, 10458, monnier

> From: Lars Ingebrigtsen <larsi@gnus.org>
> Cc: monnier@IRO.UMontreal.CA,  michael_heerdegen@web.de,  10458@debbugs.gnu.org
> Date: Sun, 20 Feb 2022 15:10:05 +0100
> 
> Eli Zaretskii <eliz@gnu.org> writes:
> 
> > It changes semantics.  The list of file names passed to a command
> > doesn't necessarily mean "open each file and process it", it could
> > mean something else, like "make a list of files".  So I don't think we
> > should do that.
> 
> Commands like "echo" will behave differently, but I tried to imagine
> other functions where this would make a difference, and I failed.  Do
> you have any examples?

Here:

   find /foo/bar -name %f

I think substituting "./bar" for %f has different semantics that
"bar", doesn't it?

Basically, any scenario where "foo" doesn't mean 'the file "foo" in
the directory where the command is invoked'.

> The old behaviour would misbehave for the vast majority of commands, so
> I think it's an improvement.

In some cases, yes.  I'm worried about those where it changes the
meaning, and the fact that we do this silently.





^ permalink raw reply	[flat|nested] 27+ messages in thread

* bug#10458: 24.0.92; ! in dired on a file starting with a hyphen
  2022-02-20 14:23         ` Eli Zaretskii
@ 2022-02-20 14:31           ` Lars Ingebrigtsen
  2022-02-20 14:40             ` Eli Zaretskii
  0 siblings, 1 reply; 27+ messages in thread
From: Lars Ingebrigtsen @ 2022-02-20 14:31 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: michael_heerdegen, 10458, monnier

Eli Zaretskii <eliz@gnu.org> writes:

> Here:
>
>    find /foo/bar -name %f
>
> I think substituting "./bar" for %f has different semantics that
> "bar", doesn't it?

Hm, right.  I guess that's a possible command somebody could use (even
though it doesn't work well in general (if you've ticked several files)).

But note that it doesn't replace "bar" with "./bar" -- it only does this
if the file name starts with "-".

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no





^ permalink raw reply	[flat|nested] 27+ messages in thread

* bug#10458: 24.0.92; ! in dired on a file starting with a hyphen
  2022-02-20 14:31           ` Lars Ingebrigtsen
@ 2022-02-20 14:40             ` Eli Zaretskii
  2022-02-21 13:46               ` Lars Ingebrigtsen
  0 siblings, 1 reply; 27+ messages in thread
From: Eli Zaretskii @ 2022-02-20 14:40 UTC (permalink / raw)
  To: Lars Ingebrigtsen; +Cc: michael_heerdegen, 10458, monnier

> From: Lars Ingebrigtsen <larsi@gnus.org>
> Cc: monnier@IRO.UMontreal.CA,  michael_heerdegen@web.de,  10458@debbugs.gnu.org
> Date: Sun, 20 Feb 2022 15:31:56 +0100
> 
> But note that it doesn't replace "bar" with "./bar" -- it only does this
> if the file name starts with "-".

Sure.  Which is why the problems will be rare and subtle.

Btw, the "usual" way of telling a program "all arguments from here on
are not options" is to use "--".





^ permalink raw reply	[flat|nested] 27+ messages in thread

* bug#10458: 24.0.92; ! in dired on a file starting with a hyphen
  2022-02-20 13:50   ` Lars Ingebrigtsen
  2022-02-20 14:07     ` Eli Zaretskii
@ 2022-02-20 15:14     ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
  2022-02-21 13:49       ` Lars Ingebrigtsen
  1 sibling, 1 reply; 27+ messages in thread
From: Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2022-02-20 15:14 UTC (permalink / raw)
  To: Lars Ingebrigtsen; +Cc: michael_heerdegen, 10458

> But adding ./ to file names that start with - should be safe, I think?
> So I've now done that in Emacs 29.

The problem with that is that it's hackish and ad-hoc.  It will
sometimes do the right thing, but other times it' not what's expected
and users will find it odd.

An alternative is to pass absolute file names.  And I think it would
make sense in that case to let the user choose between relative names
and absolute names.


        Stefan






^ permalink raw reply	[flat|nested] 27+ messages in thread

* bug#10458: 24.0.92; ! in dired on a file starting with a hyphen
  2022-02-20 14:40             ` Eli Zaretskii
@ 2022-02-21 13:46               ` Lars Ingebrigtsen
  0 siblings, 0 replies; 27+ messages in thread
From: Lars Ingebrigtsen @ 2022-02-21 13:46 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: michael_heerdegen, 10458, monnier

Eli Zaretskii <eliz@gnu.org> writes:

> Btw, the "usual" way of telling a program "all arguments from here on
> are not options" is to use "--".

It's not supported by all commands, though.  (And it would fail even
more in the "find" example.)

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no





^ permalink raw reply	[flat|nested] 27+ messages in thread

* bug#10458: 24.0.92; ! in dired on a file starting with a hyphen
  2022-02-20 15:14     ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
@ 2022-02-21 13:49       ` Lars Ingebrigtsen
  2022-02-22  1:32         ` Michael Heerdegen
  2022-02-22  2:51         ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
  0 siblings, 2 replies; 27+ messages in thread
From: Lars Ingebrigtsen @ 2022-02-21 13:49 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: michael_heerdegen, 10458

Stefan Monnier <monnier@iro.umontreal.ca> writes:

> The problem with that is that it's hackish and ad-hoc.  It will
> sometimes do the right thing, but other times it' not what's expected
> and users will find it odd.

Statistically speaking, it'll work on more cases than `!' used to,
though.  I'm pretty sure.  And I think it's fine for a command like `!'
to try to DWIM.

> An alternative is to pass absolute file names.  And I think it would
> make sense in that case to let the user choose between relative names
> and absolute names.

Giving absolute names would break more stuff than the DWIM tweak,
though, so we can't default to that.  And if we can't default to having
`!' work for files like this, there isn't much point.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no





^ permalink raw reply	[flat|nested] 27+ messages in thread

* bug#10458: 24.0.92; ! in dired on a file starting with a hyphen
  2022-02-21 13:49       ` Lars Ingebrigtsen
@ 2022-02-22  1:32         ` Michael Heerdegen
  2022-02-22  1:33           ` Lars Ingebrigtsen
  2022-02-22  2:51         ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
  1 sibling, 1 reply; 27+ messages in thread
From: Michael Heerdegen @ 2022-02-22  1:32 UTC (permalink / raw)
  To: Lars Ingebrigtsen; +Cc: 10458, Stefan Monnier

Lars Ingebrigtsen <larsi@gnus.org> writes:

> Giving absolute names would break more stuff than the DWIM tweak,
> though, so we can't default to that.

What kinds of stuff would typically break if we did that?

Michael.





^ permalink raw reply	[flat|nested] 27+ messages in thread

* bug#10458: 24.0.92; ! in dired on a file starting with a hyphen
  2022-02-22  1:32         ` Michael Heerdegen
@ 2022-02-22  1:33           ` Lars Ingebrigtsen
  0 siblings, 0 replies; 27+ messages in thread
From: Lars Ingebrigtsen @ 2022-02-22  1:33 UTC (permalink / raw)
  To: Michael Heerdegen; +Cc: 10458, Stefan Monnier

Michael Heerdegen <michael_heerdegen@web.de> writes:

>> Giving absolute names would break more stuff than the DWIM tweak,
>> though, so we can't default to that.
>
> What kinds of stuff would typically break if we did that?

See Eli's example.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no





^ permalink raw reply	[flat|nested] 27+ messages in thread

* bug#10458: 24.0.92; ! in dired on a file starting with a hyphen
  2022-02-21 13:49       ` Lars Ingebrigtsen
  2022-02-22  1:32         ` Michael Heerdegen
@ 2022-02-22  2:51         ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
  2022-02-22 13:29           ` Lars Ingebrigtsen
  1 sibling, 1 reply; 27+ messages in thread
From: Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2022-02-22  2:51 UTC (permalink / raw)
  To: Lars Ingebrigtsen; +Cc: michael_heerdegen, 10458

>> The problem with that is that it's hackish and ad-hoc.  It will
>> sometimes do the right thing, but other times it' not what's expected
>> and users will find it odd.
>
> Statistically speaking, it'll work on more cases than `!' used to,
> though.  I'm pretty sure.  And I think it's fine for a command like `!'
> to try to DWIM.

I was thinking of making it less-DWIMish and leave it in control of
the user.  IOW, rather than try to magically "do the right thing" for
files starting with `-`, allow the users to request explicitly absolute
file names (maybe with a prefix command or something like that) when
*they* see it's needed.

It won't fix the user's mistakes, but it will give a simpler semantics
on which powerusers can more easily rely.


        Stefan






^ permalink raw reply	[flat|nested] 27+ messages in thread

* bug#10458: 24.0.92; ! in dired on a file starting with a hyphen
  2022-02-22  2:51         ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
@ 2022-02-22 13:29           ` Lars Ingebrigtsen
  0 siblings, 0 replies; 27+ messages in thread
From: Lars Ingebrigtsen @ 2022-02-22 13:29 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: michael_heerdegen, 10458

Stefan Monnier <monnier@iro.umontreal.ca> writes:

> I was thinking of making it less-DWIMish and leave it in control of
> the user.  IOW, rather than try to magically "do the right thing" for
> files starting with `-`, allow the users to request explicitly absolute
> file names (maybe with a prefix command or something like that) when
> *they* see it's needed.

The prefix is already taken on the `!' command...

> It won't fix the user's mistakes, but it will give a simpler semantics
> on which powerusers can more easily rely.

Using -file-names as they are is a usability problem, and may be a
security problem (the file name may have been created by someone with
the idea in mind that interpreted as a command line switch it'll lead to
nefarious results), so I don't think `!' should go back to the old
behaviour by default.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no





^ permalink raw reply	[flat|nested] 27+ messages in thread

* bug#10458: 24.0.92; ! in dired on a file starting with a hyphen
  2012-01-08 20:05 bug#10458: 24.0.92; ! in dired on a file starting with a hyphen Michael Heerdegen
  2012-01-09  1:30 ` Stefan Monnier
@ 2022-03-28  3:02 ` Drew Adams
  1 sibling, 0 replies; 27+ messages in thread
From: Drew Adams @ 2022-03-28  3:02 UTC (permalink / raw)
  To: Stefan Monnier, Lars Ingebrigtsen, michael_heerdegen@web.de,
	10458@debbugs.gnu.org

> > But adding ./ to file names that start with - should be safe, I
> > think?  So I've now done that in Emacs 29.
> 
> The problem with that is that it's hackish and ad-hoc.  It will
> sometimes do the right thing, but other times it' not what's expected
> and users will find it odd.

FWIW, I think the cure is worse than the problem.

And as Michael indicated, a similar problem was
reported in bug #2536.

No simple solution has been found.  The simplistic
one you've (apparently) adopted is, I think, a bad
idea.  Better to just document this (and similarly
for bug #2536) as a limitation of `!' (and `&' and
`M-!').

That at least gives straightforward, if limited,
behavior - easy to understand (but needs to be
documented).  Users can find other ways (e.g.
outside Dired) to take care of such (relatively
corner) cases.

That's unfortunate, but not as unfortunate as the
change you've (apparently) made.

Just one opinion.  Document the limitations, and
leave these two bugs open, hoping that Someone(TM)
at some point will dream up a real, comprehensive
solution.





^ permalink raw reply	[flat|nested] 27+ messages in thread

end of thread, other threads:[~2022-03-28  3:02 UTC | newest]

Thread overview: 27+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-01-08 20:05 bug#10458: 24.0.92; ! in dired on a file starting with a hyphen Michael Heerdegen
2012-01-09  1:30 ` Stefan Monnier
2012-01-09 17:27   ` Glenn Morris
2012-01-09 19:39     ` Eli Zaretskii
2012-01-10  0:40       ` Richard Stallman
2012-01-09 22:40     ` Stefan Monnier
2012-01-10  7:04       ` Jan D.
2012-01-10  9:02       ` Glenn Morris
2012-01-10 14:23         ` Stefan Monnier
2012-01-10 17:11           ` Glenn Morris
2012-01-10 17:18             ` Glenn Morris
2012-01-10 20:03               ` Stefan Monnier
2012-01-10 21:45                 ` Jan Djärv
2022-02-20 13:50   ` Lars Ingebrigtsen
2022-02-20 14:07     ` Eli Zaretskii
2022-02-20 14:10       ` Lars Ingebrigtsen
2022-02-20 14:23         ` Eli Zaretskii
2022-02-20 14:31           ` Lars Ingebrigtsen
2022-02-20 14:40             ` Eli Zaretskii
2022-02-21 13:46               ` Lars Ingebrigtsen
2022-02-20 15:14     ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-02-21 13:49       ` Lars Ingebrigtsen
2022-02-22  1:32         ` Michael Heerdegen
2022-02-22  1:33           ` Lars Ingebrigtsen
2022-02-22  2:51         ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-02-22 13:29           ` Lars Ingebrigtsen
2022-03-28  3:02 ` Drew Adams

Code repositories for project(s) associated with this public inbox

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).