Subject: bug#47432: 28.0.50; Dired using ! or & on file should fail without command supplied

From: Jean Louis <[email-masked]>
Date: Sun, 28 Mar 2021 10:50:37 +0300

* Arthur Miller <[email-masked]> [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