Subject: Re: bug#8513: stat list file name
From: Bob Proulx <[email-masked]>
To: - - <[email-masked]>
Cc: [email-masked]
Date: Sat, 16 Apr 2011 23:51:10 -0600
List-Id: <debbugs-submit.debbugs.gnu.org>

- - wrote:
> here a small bug in stat:
> 
> stat -c %n *
> stat : option invalide -- 's'
> Saisissez « stat --help » pour plus d'informations.
> 
> ls
> -sdjfè`@$&.txt
> 
> stat is not able to list a direstory if a file start with a -

Thank you for your bug report but this is not a bug in stat but a
misunderstanding of how file globs operate with your command shell.

The '*' on your command line is expanded by the shell to all of the
files in the directory.  You have a filename that starts with a dash.
The resulting command line is the same as if you had placed the dash
on the command line yourself.

You can see this by using 'echo' to print out the command.

  $ echo stat -c %n *
  echo stat -c %n -sdjfè`@$&.txt

As you can see by using echo there is no difference between having a
file starting with a dash and placing an option with a dash on the
command line.  The only way to tell is for you to invoke the command
without the ambiguity.  Either use ./* to avoid having filenames start
with a dash or use "--" to signal to the command that there are no
further options.

Either:

  $ stat -c %n ./*

Or:

  $ stat -c %n -- *

Bob