unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#47432: 28.0.50; Dired using ! or & on file should fail without command supplied
@ 2021-03-27  7:09 Jean Louis
  2021-03-27  7:51 ` Arthur Miller
  2021-03-28 14:03 ` Lars Ingebrigtsen
  0 siblings, 2 replies; 15+ messages in thread
From: Jean Louis @ 2021-03-27  7:09 UTC (permalink / raw)
  To: 47432


In Dired, when using ! or & on a file, it should file if there is no
command supplied.

This is what happens if I use ! on file ~/.asoundrc but without
supplying command, just pressing RET:

/bin/bash: line 1: .asoundrc: command not found

But it should not, if command is not supplied in:
(dired-do-shell-command COMMAND &optional ARG FILE-LIST) -- then it
shall rather silently fail or tell "Command not entered" or nothing to
do.

Same for (dired-do-async-shell-command COMMAND &optional ARG FILE-LIST)





In GNU Emacs 28.0.50 (build 2, x86_64-pc-linux-gnu, X toolkit, cairo version 1.17.4, Xaw scroll bars)
 of 2021-03-22 built on protected.rcdrun.com
Repository revision: cb5d1fe1aa9f280d60fcb33b58fc83ace3d95081
Repository branch: master
Windowing system distributor 'The X.Org Foundation', version 11.0.12010000
Configured using:
 'configure --with-x-toolkit=lucid'

Configured features:
ACL CAIRO DBUS FREETYPE GIF GLIB GMP GNUTLS GPM GSETTINGS HARFBUZZ JPEG
JSON LCMS2 LIBOTF LIBSYSTEMD LIBXML2 M17N_FLT MODULES NOTIFY INOTIFY
PDUMPER PNG RSVG SOUND THREADS TIFF TOOLKIT_SCROLL_BARS X11 XDBE XIM XPM
LUCID ZLIB

Important settings:
  value of $LC_ALL: en_US.UTF-8
  value of $LANG: de_DE.UTF-8
  value of $XMODIFIERS: @im=exwm-xim
  locale-coding-system: utf-8-unix

Major mode: Dired by name

Minor modes in effect:
  shell-dirtrack-mode: t
  tooltip-mode: t
  global-eldoc-mode: t
  electric-indent-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

Load-path shadows:
None found.

Features:
(shadow sort mail-extr emacsbug message rmc puny rfc822 mml mml-sec epa
derived epg epg-config gnus-util rmail rmail-loaddefs auth-source cl-seq
eieio eieio-core cl-macs eieio-loaddefs password-cache json map
text-property-search time-date subr-x seq byte-opt gv bytecomp
byte-compile cconv mm-decode mm-bodies mm-encode mail-parse rfc2231
mailabbrev gmm-utils mailheader sendmail rfc2047 rfc2045 ietf-drums
mm-util mail-prsvr mail-utils shell pcomplete comint ansi-color ring
dired-aux cl-loaddefs cl-lib dired dired-loaddefs iso-transl tooltip
eldoc electric uniquify ediff-hook vc-hooks lisp-float-type mwheel
term/x-win x-win term/common-win x-dnd tool-bar dnd fontset image
regexp-opt fringe tabulated-list replace newcomment text-mode elisp-mode
lisp-mode prog-mode register page tab-bar menu-bar rfn-eshadow isearch
easymenu timer select scroll-bar mouse jit-lock font-lock syntax
font-core term/tty-colors frame minibuffer cl-generic cham georgian
utf-8-lang misc-lang vietnamese tibetan thai tai-viet lao korean
japanese eucjp-ms cp51932 hebrew greek romanian slovak czech european
ethiopic indian cyrillic chinese composite charscript charprop
case-table epa-hook jka-cmpr-hook help simple abbrev obarray
cl-preloaded nadvice button loaddefs faces cus-face macroexp files
window text-properties overlay sha1 md5 base64 format env code-pages
mule custom widget hashtable-print-readable backquote threads dbusbind
inotify lcms2 dynamic-setting system-font-setting font-render-setting
cairo x-toolkit x multi-tty make-network-process emacs)

Memory information:
((conses 16 69609 8322)
 (symbols 48 7679 0)
 (strings 32 22446 2230)
 (string-bytes 1 727018)
 (vectors 16 14870)
 (vector-slots 8 197548 10923)
 (floats 8 23 36)
 (intervals 56 2480 0)
 (buffers 992 13))

-- 
Thanks,
Jean Louis
⎔ λ 🄯 𝍄 𝌡 𝌚





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

* bug#47432: 28.0.50; Dired using ! or & on file should fail without command supplied
  2021-03-27  7:09 bug#47432: 28.0.50; Dired using ! or & on file should fail without command supplied Jean Louis
@ 2021-03-27  7:51 ` Arthur Miller
  2021-03-27  8:42   ` Jean Louis
  2021-03-28 14:03 ` Lars Ingebrigtsen
  1 sibling, 1 reply; 15+ messages in thread
From: Arthur Miller @ 2021-03-27  7:51 UTC (permalink / raw)
  To: Jean Louis; +Cc: 47432

Jean Louis <bugs@gnu.support> writes:

> In Dired, when using ! or & on a file, it should file if there is no
> command supplied.
>
> This is what happens if I use ! on file ~/.asoundrc but without
> supplying command, just pressing RET:
>
> /bin/bash: line 1: .asoundrc: command not found
>
> But it should not, if command is not supplied in:
> (dired-do-shell-command COMMAND &optional ARG FILE-LIST) -- then it
> shall rather silently fail or tell "Command not entered" or nothing to
> do.

Why is "Command not entered" to prefer to "Command not found"?

Message as a message ....


>
> Same for (dired-do-async-shell-command COMMAND &optional ARG FILE-LIST)
>
>
>
>
>
> In GNU Emacs 28.0.50 (build 2, x86_64-pc-linux-gnu, X toolkit, cairo version 1.17.4, Xaw scroll bars)
>  of 2021-03-22 built on protected.rcdrun.com
> Repository revision: cb5d1fe1aa9f280d60fcb33b58fc83ace3d95081
> Repository branch: master
> Windowing system distributor 'The X.Org Foundation', version 11.0.12010000
> Configured using:
>  'configure --with-x-toolkit=lucid'
>
> Configured features:
> ACL CAIRO DBUS FREETYPE GIF GLIB GMP GNUTLS GPM GSETTINGS HARFBUZZ JPEG
> JSON LCMS2 LIBOTF LIBSYSTEMD LIBXML2 M17N_FLT MODULES NOTIFY INOTIFY
> PDUMPER PNG RSVG SOUND THREADS TIFF TOOLKIT_SCROLL_BARS X11 XDBE XIM XPM
> LUCID ZLIB
>
> Important settings:
>   value of $LC_ALL: en_US.UTF-8
>   value of $LANG: de_DE.UTF-8
>   value of $XMODIFIERS: @im=exwm-xim
>   locale-coding-system: utf-8-unix
>
> Major mode: Dired by name
>
> Minor modes in effect:
>   shell-dirtrack-mode: t
>   tooltip-mode: t
>   global-eldoc-mode: t
>   electric-indent-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
>
> Load-path shadows:
> None found.
>
> Features:
> (shadow sort mail-extr emacsbug message rmc puny rfc822 mml mml-sec epa
> derived epg epg-config gnus-util rmail rmail-loaddefs auth-source cl-seq
> eieio eieio-core cl-macs eieio-loaddefs password-cache json map
> text-property-search time-date subr-x seq byte-opt gv bytecomp
> byte-compile cconv mm-decode mm-bodies mm-encode mail-parse rfc2231
> mailabbrev gmm-utils mailheader sendmail rfc2047 rfc2045 ietf-drums
> mm-util mail-prsvr mail-utils shell pcomplete comint ansi-color ring
> dired-aux cl-loaddefs cl-lib dired dired-loaddefs iso-transl tooltip
> eldoc electric uniquify ediff-hook vc-hooks lisp-float-type mwheel
> term/x-win x-win term/common-win x-dnd tool-bar dnd fontset image
> regexp-opt fringe tabulated-list replace newcomment text-mode elisp-mode
> lisp-mode prog-mode register page tab-bar menu-bar rfn-eshadow isearch
> easymenu timer select scroll-bar mouse jit-lock font-lock syntax
> font-core term/tty-colors frame minibuffer cl-generic cham georgian
> utf-8-lang misc-lang vietnamese tibetan thai tai-viet lao korean
> japanese eucjp-ms cp51932 hebrew greek romanian slovak czech european
> ethiopic indian cyrillic chinese composite charscript charprop
> case-table epa-hook jka-cmpr-hook help simple abbrev obarray
> cl-preloaded nadvice button loaddefs faces cus-face macroexp files
> window text-properties overlay sha1 md5 base64 format env code-pages
> mule custom widget hashtable-print-readable backquote threads dbusbind
> inotify lcms2 dynamic-setting system-font-setting font-render-setting
> cairo x-toolkit x multi-tty make-network-process emacs)
>
> Memory information:
> ((conses 16 69609 8322)
>  (symbols 48 7679 0)
>  (strings 32 22446 2230)
>  (string-bytes 1 727018)
>  (vectors 16 14870)
>  (vector-slots 8 197548 10923)
>  (floats 8 23 36)
>  (intervals 56 2480 0)
>  (buffers 992 13))





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

* bug#47432: 28.0.50; Dired using ! or & on file should fail without command supplied
  2021-03-27  7:51 ` Arthur Miller
@ 2021-03-27  8:42   ` Jean Louis
  2021-03-27 13:59     ` Arthur Miller
  0 siblings, 1 reply; 15+ messages in thread
From: Jean Louis @ 2021-03-27  8:42 UTC (permalink / raw)
  To: Arthur Miller; +Cc: 47432

* Arthur Miller <arthur.miller@live.com> [2021-03-27 10:52]:
> Jean Louis <bugs@gnu.support> writes:
> 
> > In Dired, when using ! or & on a file, it should file if there is no
> > command supplied.
> >
> > This is what happens if I use ! on file ~/.asoundrc but without
> > supplying command, just pressing RET:
> >
> > /bin/bash: line 1: .asoundrc: command not found
> >
> > But it should not, if command is not supplied in:
> > (dired-do-shell-command COMMAND &optional ARG FILE-LIST) -- then it
> > shall rather silently fail or tell "Command not entered" or nothing to
> > do.
> 
> Why is "Command not entered" to prefer to "Command not found"?

It is meant as example, I leave those decisions to developers.

Now I can see that ! and & without command are acting on the file as
the file should be executed.

Let us say I have Screenshot.pl executable file, if I run ! on it, the
file is executed.

This means there was attempt to execute ~/.asoundrc -- I find that
insecure and not logical.

And I do not understand it quite how it works. Was there an attempt to
execute program with bash?

Why should there be attempt to execute non-executable files?







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

* bug#47432: 28.0.50; Dired using ! or & on file should fail without command supplied
  2021-03-27  8:42   ` Jean Louis
@ 2021-03-27 13:59     ` Arthur Miller
  2021-03-27 18:54       ` Jean Louis
  0 siblings, 1 reply; 15+ messages in thread
From: Arthur Miller @ 2021-03-27 13:59 UTC (permalink / raw)
  To: Jean Louis; +Cc: 47432

Jean Louis <bugs@gnu.support> writes:

> * Arthur Miller <arthur.miller@live.com> [2021-03-27 10:52]:
>> Jean Louis <bugs@gnu.support> writes:
>> 
>> > In Dired, when using ! or & on a file, it should file if there is no
>> > command supplied.
>> >
>> > This is what happens if I use ! on file ~/.asoundrc but without
>> > supplying command, just pressing RET:
>> >
>> > /bin/bash: line 1: .asoundrc: command not found
>> >
>> > But it should not, if command is not supplied in:
>> > (dired-do-shell-command COMMAND &optional ARG FILE-LIST) -- then it
>> > shall rather silently fail or tell "Command not entered" or nothing to
>> > do.
>> 
>> Why is "Command not entered" to prefer to "Command not found"?
>
> It is meant as example, I leave those decisions to developers.
>
> Now I can see that ! and & without command are acting on the file as
> the file should be executed.
>
> Let us say I have Screenshot.pl executable file, if I run ! on it, the
> file is executed.

Ja. I guess there is a shebang on it so bash invoked perl interpreter
and executed the file.

> This means there was attempt to execute ~/.asoundrc -- I find that
> insecure and not logical.

Ja. Because you invoked a command that will execute a script on a
file. And since file wasn't executable it failed. So why is it insecured?

> And I do not understand it quite how it works. Was there an attempt to
> execute program with bash?

How you seen the docs? For example C-h k ! RET:

Signature
(dired-do-shell-command COMMAND &optional ARG FILE-LIST)

Documentation
Run a shell command COMMAND on the marked files.


> Why should there be attempt to execute non-executable files?

Because you asked it to by calling ! or & on a file in Dired.






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

* bug#47432: 28.0.50; Dired using ! or & on file should fail without command supplied
  2021-03-27 13:59     ` Arthur Miller
@ 2021-03-27 18:54       ` Jean Louis
  2021-03-27 20:28         ` Arthur Miller
  0 siblings, 1 reply; 15+ messages in thread
From: Jean Louis @ 2021-03-27 18:54 UTC (permalink / raw)
  To: Arthur Miller; +Cc: 47432

* Arthur Miller <arthur.miller@live.com> [2021-03-27 17:00]:
> How you seen the docs? For example C-h k ! RET:
> 
> Signature
> (dired-do-shell-command COMMAND &optional ARG FILE-LIST)
> 
> Documentation
> Run a shell command COMMAND on the marked files.
> 
> 
> > Why should there be attempt to execute non-executable files?
> 
> Because you asked it to by calling ! or & on a file in Dired.

I have got a feeling you have not get really what is taking place:

1. Dired mode
2. Come on any file or directory, not executable
3. Press ! or &
4. Press ENTER
5. Get error, it can be different, depending of situation. Like
   /usr/bin/bash: line 1: admin_Leo: command not found where "admin_Leo"
    is directory

I cannot see in the documentation that ! or & in Dired is supposed to
run that specific marked file as COMMAND. I can understand that
command is asked and user should enter the command. But I do not see
that the marked file is supposed to be executed as COMMAND when
command is not manually entered by user.

Why is Emacs trying to execute a directory?

Why is Emacs trying to execute non-executable file?

- documentation of the function should maybe reflect that ! or & is
  meant to execute the marked file or current file in Dired if no
  COMMAND is supplied manually.

- Emacs should stop trying to execute directories or non executable
  files.
  





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

* bug#47432: 28.0.50; Dired using ! or & on file should fail without command supplied
  2021-03-27 18:54       ` Jean Louis
@ 2021-03-27 20:28         ` Arthur Miller
  2021-03-28  7:50           ` Jean Louis
  0 siblings, 1 reply; 15+ messages in thread
From: Arthur Miller @ 2021-03-27 20:28 UTC (permalink / raw)
  To: Jean Louis; +Cc: 47432

Jean Louis <bugs@gnu.support> writes:

> * Arthur Miller <arthur.miller@live.com> [2021-03-27 17:00]:
>> How you seen the docs? For example C-h k ! RET:
>> 
>> Signature
>> (dired-do-shell-command COMMAND &optional ARG FILE-LIST)
>> 
>> Documentation
>> Run a shell command COMMAND on the marked files.
>> 
>> 
>> > Why should there be attempt to execute non-executable files?
>> 
>> Because you asked it to by calling ! or & on a file in Dired.
>
> I have got a feeling you have not get really what is taking place:
>
> 1. Dired mode
> 2. Come on any file or directory, not executable
> 3. Press ! or &
> 4. Press ENTER
> 5. Get error, it can be different, depending of situation. Like
>    /usr/bin/bash: line 1: admin_Leo: command not found where "admin_Leo"
>     is directory
>
> I cannot see in the documentation that ! or & in Dired is supposed to
> run that specific marked file as COMMAND. I can understand that
> command is asked and user should enter the command. But I do not see
> that the marked file is supposed to be executed as COMMAND when
> command is not manually entered by user.
>
> Why is Emacs trying to execute a directory?
>
> Why is Emacs trying to execute non-executable file?
>
> - documentation of the function should maybe reflect that ! or & is
>   meant to execute the marked file or current file in Dired if no
>   COMMAND is supplied manually.
>
> - Emacs should stop trying to execute directories or non executable
>   files.

Emacs is not executing them, Emacs is passing them to the shell. Same
happends as if you tried to execute that file from the command
prompt. If you don't supply a COMMAND it just passes entire list to
shell and shell tries to execute the first file in the list. If there is
a shebang in that file it will get executed in proper interpretter. If
not shell will repport you an error. Would you try to execute your
admin_Leo in terminal? Guess not. So why would you try in Dired?

You are asking it to do stuff that shell already does. Emacs can
probably implement shell functionality on it's own, but I guess
it was simplicity of implementation in that case.

Doing extra checks would save one process invocation, but does it really
matter in this case?





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

* bug#47432: 28.0.50; Dired using ! or & on file should fail without command supplied
  2021-03-27 20:28         ` Arthur Miller
@ 2021-03-28  7:50           ` Jean Louis
  2021-03-28  8:13             ` Eli Zaretskii
  0 siblings, 1 reply; 15+ messages in thread
From: Jean Louis @ 2021-03-28  7:50 UTC (permalink / raw)
  To: Arthur Miller; +Cc: 47432

* Arthur Miller <arthur.miller@live.com> [2021-03-27 23:29]:
> Emacs is not executing them, Emacs is passing them to the shell. Same
> happends as if you tried to execute that file from the command
> prompt.

Maybe in your opinion, not that I have same opinion, look:

In Emacs, I press ! because I wish to write a command to be executed
on the file, not to execute empty command which I did not write. When
I press RET without entering command, I expect nothing to happen.

As in shell when I press RET after prompt, nothing happens.

$ RET
$

In Dired, if cursor is positioned on directory "admin_leo", the prompt
says:

! on admin_leo:

Even the prompt is pointing to direction that command is to be
executed on the file "admin_leo". If I press RET without entering any
command, why is there an error? It should not be there.

> If you don't supply a COMMAND it just passes entire list to shell
> and shell tries to execute the first file in the list. If there is a
> shebang in that file it will get executed in proper interpretter. If
> not shell will repport you an error. Would you try to execute your
> admin_Leo in terminal? Guess not. So why would you try in Dired?

That is your opinion that I have "tried executing admin_Leo" in
terminal, not that I share it.

In my opinion that is a bug:

- description of function does not say that empty RET should be
  considered "COMMAND", there is no mentioning (I could miss it maybe)
  that file itself will be executed;

- info manual does not reflect that what you are speaking. It says:
  "The Dired command ‘!’ (‘dired-do-shell-command’) reads a shell
  command string in the minibuffer, and runs that shell command on one
  or more files."

Now if I press RET instead of providing "command string in the
minibuffer" what is supposed to happen? I don't think there should be
nonsensical error to the user.

From manual:

File: emacs.info,  Node: Shell Commands in Dired,  Next: Transforming File Names,  Prev: Operating on Files,  Up: Dired

30.8 Shell Commands in Dired
============================

The Dired command ‘!’ (‘dired-do-shell-command’) reads a shell command
string in the minibuffer, and runs that shell command on one or more
files.  The files that the shell command operates on are determined in
the usual way for Dired commands (*note Operating on Files::).  The
command ‘X’ is a synonym for ‘!’.

If I press in this mail-mode buffer M-! I am invited to enter string
that will be executed as shell command, if I then press RET, I get
message: (Shell command succeeded with no output) -- this is also
wrong in my opinion, as if I have not entered any command, it should
not say "Shell command succeeded" -- rather, "No shell command
supplied." -- as trying to execute empty string as command does not
make sense.

When I press M-& in mail-mode buffer (or other but dired), and I press
RET, I get message like: ": finished." -- which is also incorrect
message, it also means nothing specific. It does not help user. It is
confusing. What means colon in this space and how is colon finished?
It is bug as if there was no command supplied message should say
something like "No command supplied."

In Dired if I press RET after !, without supplying command, it should
say something like "No command supplied.".

If it is expected to run the file where cursors is located, than this
shall be reflected in the manual, I do not see that fact, but I can
see that I can do ! on executable file and run that file this
way. However, manual and function should be aligned in its
descriptions.

However, why should ! or & in Dired try to execute non-executable
file, they shall verify if it is directory, if no command was
supplied, they should not try to execute directory name as shell
command.

There shall be conditions before trying to do the impossible, so that
user get proper message.

Does it matter? Yes it does matter for quality of interaction.

Jean







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

* bug#47432: 28.0.50; Dired using ! or & on file should fail without command supplied
  2021-03-28  7:50           ` Jean Louis
@ 2021-03-28  8:13             ` Eli Zaretskii
  2021-03-29 18:51               ` Jean Louis
  0 siblings, 1 reply; 15+ messages in thread
From: Eli Zaretskii @ 2021-03-28  8:13 UTC (permalink / raw)
  To: Jean Louis; +Cc: 47432, arthur.miller

> Date: Sun, 28 Mar 2021 10:50:37 +0300
> From: Jean Louis <bugs@gnu.support>
> Cc: 47432@debbugs.gnu.org
> 
> * Arthur Miller <arthur.miller@live.com> [2021-03-27 23:29]:
> > Emacs is not executing them, Emacs is passing them to the shell. Same
> > happends as if you tried to execute that file from the command
> > prompt.
> 
> Maybe in your opinion, not that I have same opinion, look:
> 
> In Emacs, I press ! because I wish to write a command to be executed
> on the file, not to execute empty command which I did not write. When
> I press RET without entering command, I expect nothing to happen.

Is this expectation consistent with the documentation of '!'?
Specifically, how are you sure that an empty COMMAND does nothing in
the shell?

> As in shell when I press RET after prompt, nothing happens.
> 
> $ RET
> $

With that shell, perhaps.  But Emacs doesn't know what shell will be
invoked, it depends on various factors outside of Dired's control.

> - description of function does not say that empty RET should be
>   considered "COMMAND", there is no mentioning (I could miss it maybe)
>   that file itself will be executed;
> 
> - info manual does not reflect that what you are speaking. It says:
>   "The Dired command ‘!’ (‘dired-do-shell-command’) reads a shell
>   command string in the minibuffer, and runs that shell command on one
>   or more files."

None of the above says anything about the effect of an empty string as
COMMAND.

> If I press in this mail-mode buffer M-! I am invited to enter string
> that will be executed as shell command, if I then press RET, I get
> message: (Shell command succeeded with no output) -- this is also
> wrong in my opinion, as if I have not entered any command, it should
> not say "Shell command succeeded" -- rather, "No shell command
> supplied." -- as trying to execute empty string as command does not
> make sense.

You explicitly ignore the fact that many Emacs commands provide
defaults when the user just types RET?

> When I press M-& in mail-mode buffer (or other but dired), and I press
> RET, I get message like: ": finished." -- which is also incorrect
> message, it also means nothing specific. It does not help user. It is
> confusing. What means colon in this space and how is colon finished?

The colon is a shell command that does nothing.  I's probably
explained in the manual of your shell.

> However, why should ! or & in Dired try to execute non-executable
> file, they shall verify if it is directory, if no command was
> supplied, they should not try to execute directory name as shell
> command.

You are assigning certain semantics to the command arguments, but the
real semantics is assigned by the shell, not by Emacs.  As Arthur
says, Emacs just passes the arguments to the shell.

So I think your expectations, while they are true in many cases, don't
have to be true always.





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

* bug#47432: 28.0.50; Dired using ! or & on file should fail without command supplied
  2021-03-27  7:09 bug#47432: 28.0.50; Dired using ! or & on file should fail without command supplied Jean Louis
  2021-03-27  7:51 ` Arthur Miller
@ 2021-03-28 14:03 ` Lars Ingebrigtsen
  2021-03-28 15:00   ` Andreas Schwab
  2021-03-29 18:34   ` Jean Louis
  1 sibling, 2 replies; 15+ messages in thread
From: Lars Ingebrigtsen @ 2021-03-28 14:03 UTC (permalink / raw)
  To: Jean Louis; +Cc: 47432

Jean Louis <bugs@gnu.support> writes:

> In Dired, when using ! or & on a file, it should file if there is no
> command supplied.
>
> This is what happens if I use ! on file ~/.asoundrc but without
> supplying command, just pressing RET:
>
> /bin/bash: line 1: .asoundrc: command not found
>
> But it should not, if command is not supplied in:
> (dired-do-shell-command COMMAND &optional ARG FILE-LIST) -- then it
> shall rather silently fail or tell "Command not entered" or nothing to
> do.

I think that would be a bit odd.  But I see that the doc string doesn't
explicitly say that happens here, so I've added the following sentence
to the doc string in Emacs 28:

----
When executing, FILE-LIST is appended to the COMMAND string.
----

And that's what happening here -- COMMAND is "", and FILE-LIST is
appended to that, and then executed.

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





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

* bug#47432: 28.0.50; Dired using ! or & on file should fail without command supplied
  2021-03-28 14:03 ` Lars Ingebrigtsen
@ 2021-03-28 15:00   ` Andreas Schwab
  2021-03-28 15:06     ` Lars Ingebrigtsen
  2021-03-29 18:55     ` Jean Louis
  2021-03-29 18:34   ` Jean Louis
  1 sibling, 2 replies; 15+ messages in thread
From: Andreas Schwab @ 2021-03-28 15:00 UTC (permalink / raw)
  To: Lars Ingebrigtsen; +Cc: 47432, Jean Louis

On Mär 28 2021, Lars Ingebrigtsen wrote:

> I think that would be a bit odd.  But I see that the doc string doesn't
> explicitly say that happens here, so I've added the following sentence
> to the doc string in Emacs 28:
>
> ----
> When executing, FILE-LIST is appended to the COMMAND string.
> ----

No, this is very wrong.  The docstring already adequately and correctly
documents that case:

    Otherwise, this runs COMMAND on each file individually with the
    file name added at the end of COMMAND (separated by a space).

Andreas.

-- 
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510  2552 DF73 E780 A9DA AEC1
"And now for something completely different."





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

* bug#47432: 28.0.50; Dired using ! or & on file should fail without command supplied
  2021-03-28 15:00   ` Andreas Schwab
@ 2021-03-28 15:06     ` Lars Ingebrigtsen
  2021-03-29 18:55     ` Jean Louis
  1 sibling, 0 replies; 15+ messages in thread
From: Lars Ingebrigtsen @ 2021-03-28 15:06 UTC (permalink / raw)
  To: Andreas Schwab; +Cc: 47432, Jean Louis

Andreas Schwab <schwab@linux-m68k.org> writes:

> No, this is very wrong.  The docstring already adequately and correctly
> documents that case:
>
>     Otherwise, this runs COMMAND on each file individually with the
>     file name added at the end of COMMAND (separated by a space).

Right; I've reverted the patch.

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





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

* bug#47432: 28.0.50; Dired using ! or & on file should fail without command supplied
  2021-03-28 14:03 ` Lars Ingebrigtsen
  2021-03-28 15:00   ` Andreas Schwab
@ 2021-03-29 18:34   ` Jean Louis
  1 sibling, 0 replies; 15+ messages in thread
From: Jean Louis @ 2021-03-29 18:34 UTC (permalink / raw)
  To: Lars Ingebrigtsen; +Cc: 47432

* Lars Ingebrigtsen <larsi@gnus.org> [2021-03-28 17:04]:
> Jean Louis <bugs@gnu.support> writes:
> 
> > In Dired, when using ! or & on a file, it should file if there is no
> > command supplied.
> >
> > This is what happens if I use ! on file ~/.asoundrc but without
> > supplying command, just pressing RET:
> >
> > /bin/bash: line 1: .asoundrc: command not found
> >
> > But it should not, if command is not supplied in:
> > (dired-do-shell-command COMMAND &optional ARG FILE-LIST) -- then it
> > shall rather silently fail or tell "Command not entered" or nothing to
> > do.
> 
> I think that would be a bit odd.  But I see that the doc string doesn't
> explicitly say that happens here, so I've added the following sentence
> to the doc string in Emacs 28:
> 
> ----
> When executing, FILE-LIST is appended to the COMMAND string.
> ----
> 
> And that's what happening here -- COMMAND is "", and FILE-LIST is
> appended to that, and then executed.

Yes, as documentation and functionality should be in alignment.

Please tell me why is that useful to append the file list when there
is no command?

For example if I run ! on marked directories:

/usr/bin/bash: line 1: admin_Leo: command not found
/usr/bin/bash: line 1: babel-6KitXT: command not found
/usr/bin/bash: line 1: babel-cyz28q: command not found
/usr/bin/bash: line 1: babel-YJWc0L: command not found
/usr/bin/bash: line 1: babel-ZlWVex: command not found
/usr/bin/bash: line 1: backup: command not found
C-x C-g is undefined

I would like to know how is that useful.

Thanks,
Jean Louis

Take action in Free Software Foundation campaigns:
https://www.fsf.org/campaigns






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

* bug#47432: 28.0.50; Dired using ! or & on file should fail without command supplied
  2021-03-28  8:13             ` Eli Zaretskii
@ 2021-03-29 18:51               ` Jean Louis
  2021-03-29 19:23                 ` Eli Zaretskii
  0 siblings, 1 reply; 15+ messages in thread
From: Jean Louis @ 2021-03-29 18:51 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: 47432, Lars Ingebrigtsen, arthur.miller

* Eli Zaretskii <eliz@gnu.org> [2021-03-28 11:13]:
> > Date: Sun, 28 Mar 2021 10:50:37 +0300
> > From: Jean Louis <bugs@gnu.support>
> > Cc: 47432@debbugs.gnu.org
> > 
> > * Arthur Miller <arthur.miller@live.com> [2021-03-27 23:29]:
> > > Emacs is not executing them, Emacs is passing them to the shell. Same
> > > happends as if you tried to execute that file from the command
> > > prompt.
> > 
> > Maybe in your opinion, not that I have same opinion, look:
> > 
> > In Emacs, I press ! because I wish to write a command to be executed
> > on the file, not to execute empty command which I did not write. When
> > I press RET without entering command, I expect nothing to happen.
> 
> Is this expectation consistent with the documentation of '!'?
> Specifically, how are you sure that an empty COMMAND does nothing in
> the shell?

In some cases it does call the marked file, but those other cases
should be excluded -- or documentation improved to tell users why is
it so.

Since Larse explained about the concatenation of COMMAND and
FILE-LIST, I understand technically why is that happening, but I do
not understand logic behind it.

When there are let us say 50 images that I wish to convert, and if I
forget to give a command like

! * [on 50 files]: mogrify -format jpg

and instead I give ""

then all those pictures will be "executed", attempted to be
executed. That makes no sense to me

> > - description of function does not say that empty RET should be
> >   considered "COMMAND", there is no mentioning (I could miss it maybe)
> >   that file itself will be executed;
> > 
> > - info manual does not reflect that what you are speaking. It says:
> >   "The Dired command ‘!’ (‘dired-do-shell-command’) reads a shell
> >   command string in the minibuffer, and runs that shell command on one
> >   or more files."
> 
> None of the above says anything about the effect of an empty string as
> COMMAND.

That is basically what I am pointing out, thank you, but seem that we
have disagreement.

In my opinion:

- it should be clear WHY is it useful to allow empty string to be
  accepted as COMMAND as the logical function should execute COMMAND
  as non-empty string;

- document that so that it becomes clear; I am myself still trying to
  understand as the prompt says to execute ON files, not to execute
  files.

- documentation of the function and info manual should be aligned with
  that functionality;

- and still I think that images and various files, directories, should
  not be executed. Only if the file has executable bit it should be
  executed -- this is current behavior on executable files.

Let me give you more from researching how it works:

- if there is script.pl or script.sh, then ! or & will verify for
  executable bit, and execute it only if set; BUT it is not executing
  THE FILE which is marked!

  Replicate it by putting one non-executable script.sh in your PATH
  and going to directory that is not in your path that has executable
  script.sh in that path, do ! or & on that command.

  script.sh:

  #!/bin/bash
  echo Hello, it worked

  ---- 
  put same script in your PATH, like maybe ~/bin/script.sh and make it
  non-executable.

  put same file, but executable in other directory ~/tmp/script.sh

  go with Dired to ~/tmp/script.sh as it is executable, so do ! or &
  and it will try to execute which file?

  Definitely not ~/tmp/script.sh but it will try to execute
  "script.sh" in PATH.

So think about that, there is no logic that FILE-LIST is appended to
empty COMMAND like "" as that FILE-LIST is not getting executed
really, so it is misleading the user.

Jean Louis

Take action in Free Software Foundation campaigns:
https://www.fsf.org/campaigns





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

* bug#47432: 28.0.50; Dired using ! or & on file should fail without command supplied
  2021-03-28 15:00   ` Andreas Schwab
  2021-03-28 15:06     ` Lars Ingebrigtsen
@ 2021-03-29 18:55     ` Jean Louis
  1 sibling, 0 replies; 15+ messages in thread
From: Jean Louis @ 2021-03-29 18:55 UTC (permalink / raw)
  To: Andreas Schwab; +Cc: 47432, Lars Ingebrigtsen

 Andreas Schwab <schwab@linux-m68k.org> [2021-03-28 18:00]:
> On Mär 28 2021, Lars Ingebrigtsen wrote:
> 
> > I think that would be a bit odd.  But I see that the doc string doesn't
> > explicitly say that happens here, so I've added the following sentence
> > to the doc string in Emacs 28:
> >
> > ----
> > When executing, FILE-LIST is appended to the COMMAND string.
> > ----
> 
> No, this is very wrong.  The docstring already adequately and correctly
> documents that case:
> 
>     Otherwise, this runs COMMAND on each file individually with the
>     file name added at the end of COMMAND (separated by a space).

I probably do not understand what you two understand, what I don't
understand why should FILE-LIST be appended to empty string, as those
files will not be executed unless they are in path, and unless they
are executables.

! and & should verify if those files are executables -- and if not,
  not execute images and directors -- OR -- maybe developer shall
  decide what is meant with ! or & -- is it maybe meant to execute
  marked files? And if so, then marked files shall be executed in the
  default-directory with prepended ./ and not as general system
  commands searched only in $PATH.

-- 
Jean

Take action in Free Software Foundation campaigns:
https://www.fsf.org/campaigns





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

* bug#47432: 28.0.50; Dired using ! or & on file should fail without command supplied
  2021-03-29 18:51               ` Jean Louis
@ 2021-03-29 19:23                 ` Eli Zaretskii
  0 siblings, 0 replies; 15+ messages in thread
From: Eli Zaretskii @ 2021-03-29 19:23 UTC (permalink / raw)
  To: Jean Louis; +Cc: 47432, larsi, arthur.miller

> Date: Mon, 29 Mar 2021 21:51:41 +0300
> From: Jean Louis <bugs@gnu.support>
> Cc: arthur.miller@live.com, 47432@debbugs.gnu.org,
>   Lars Ingebrigtsen <larsi@gnus.org>
> 
> Let me give you more from researching how it works:
> 
> - if there is script.pl or script.sh, then ! or & will verify for
>   executable bit, and execute it only if set; BUT it is not executing
>   THE FILE which is marked!
> 
>   Replicate it by putting one non-executable script.sh in your PATH
>   and going to directory that is not in your path that has executable
>   script.sh in that path, do ! or & on that command.
> 
>   script.sh:
> 
>   #!/bin/bash
>   echo Hello, it worked
> 
>   ---- 
>   put same script in your PATH, like maybe ~/bin/script.sh and make it
>   non-executable.
> 
>   put same file, but executable in other directory ~/tmp/script.sh
> 
>   go with Dired to ~/tmp/script.sh as it is executable, so do ! or &
>   and it will try to execute which file?
> 
>   Definitely not ~/tmp/script.sh but it will try to execute
>   "script.sh" in PATH.
> 
> So think about that, there is no logic that FILE-LIST is appended to
> empty COMMAND like "" as that FILE-LIST is not getting executed
> really, so it is misleading the user.

You are again assigning the shell commands the logic and features of a
typical Posix shell.  But that's just one possible type of shell, and
one possible type of logic.  Emacs leaves it to the user to do what
the user wants, while you suggest that Emacs assumes something about
the shell and the semantics of what the user intends to do.





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

end of thread, other threads:[~2021-03-29 19:23 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-03-27  7:09 bug#47432: 28.0.50; Dired using ! or & on file should fail without command supplied Jean Louis
2021-03-27  7:51 ` Arthur Miller
2021-03-27  8:42   ` Jean Louis
2021-03-27 13:59     ` Arthur Miller
2021-03-27 18:54       ` Jean Louis
2021-03-27 20:28         ` Arthur Miller
2021-03-28  7:50           ` Jean Louis
2021-03-28  8:13             ` Eli Zaretskii
2021-03-29 18:51               ` Jean Louis
2021-03-29 19:23                 ` Eli Zaretskii
2021-03-28 14:03 ` Lars Ingebrigtsen
2021-03-28 15:00   ` Andreas Schwab
2021-03-28 15:06     ` Lars Ingebrigtsen
2021-03-29 18:55     ` Jean Louis
2021-03-29 18:34   ` Jean Louis

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).