Subject: bug#15092: Dirname Bug

From: Bernhard Voelker <[email-masked]>
Date: Wed, 14 Aug 2013 12:36:32 +0200

tags 15092 notabug
close 15092
thanks

On 08/14/2013 11:45 AM, Erik Auerswald wrote:
> Hello Axel,
> 
> On Wed, Aug 14, 2013 at 09:16:14AM +0200, Axel Spallek wrote:
>> the following throw errors:
>>
>> dirname --to-0040257282759-in.wav
>> dirname "--to-0040257282759-in.wav"
>> dirname '--to-0040257282759-in.wav'
>>
>> IMHO at least the last two ones schould work.
> 
> If the arguments to a program start with a - or --, they are assumed to be
> options. You can use -- to stop option processing:
> 
> $ dirname -- --to-0040257282759-in.wav
> .

Another way would be to prefix it by a directory name,
either fully qualified, or just the current directory:

  $ dirname "./--to-0040257282759-in.wav"
 or
  $ dirname "$(pwd)/--to-0040257282759-in.wav"

> Quoting the arguments as in your last two examples does not affect this, as
> the shell does not interpret leading - characters in the command line, the
> program called does.

Or told in another way: in your examples above, dirname(1) saw
the same string as argument in all 3 cases.

There's some help for this sort of misunderstanding in our FAQ:

http://www.gnu.org/software/coreutils/faq/coreutils-faq.html#How-do-I-remove-files-that-start-with-a-dash_003f

As this is not a bug in coreutils, I've marked it as such
and closed the bug.

Have a nice day,
Berny