Felix Lee flee@teleport.com
Felix Rauch Valenti frauch@cse.unsw.edu.au
Ferdinand fw@scenic.mine.nu
+Filipus Klutiero chealer@gmail.com
Fletcher Mattox fletcher@cs.utexas.edu
Florent Bayle florent@sarcelle.net
Florian Schlichting fschlich@cis.fu-berlin.de
@cindex non-directory suffix, stripping
@command{dirname} prints all but the final slash-delimited component of
-a string (presumably a file name, but also works on directories). Synopsis:
+@var{name}. Slashes on either side of the final component are also
+removed. If the string contains no slash, @command{dirname} prints
+@samp{.} (meaning the current directory). Synopsis:
@example
dirname @var{name}
@end example
-If @var{name} is a single component, @command{dirname} prints @samp{.}
-(meaning the current directory).
+@var{name} need not be a file name, but if it is, this operation
+effectively lists the directory that contains the final component,
+including the case when the final component is itself a directory.
@basenameAndDirname
@smallexample
# Output "/usr/bin".
dirname /usr/bin/sort
+dirname /usr/bin//.//
# Output ".".
dirname stdio.h
"),
program_name, program_name);
fputs (_("\
-Print NAME with its trailing /component removed; if NAME contains no /'s,\n\
-output `.' (meaning the current directory).\n\
+Output NAME with its last non-slash component and trailing slashes removed;\n\
+if NAME contains no /'s, output `.' (meaning the current directory).\n\
\n\
"), stdout);
fputs (HELP_OPTION_DESCRIPTION, stdout);
printf (_("\
\n\
Examples:\n\
- %s /usr/bin/sort Output \"/usr/bin\".\n\
+ %s /usr/bin/ Output \"/usr\".\n\
%s stdio.h Output \".\".\n\
"),
program_name, program_name);