GNU bug report logs -
#10342
Bug Report for command "dirname"
Previous Next
To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 10342 in the body.
You can then email your comments to 10342 AT debbugs.gnu.org in the normal way.
Toggle the display of automated, internal messages from the tracker.
Report forwarded
to
bug-coreutils <at> gnu.org
:
bug#10342
; Package
coreutils
.
(Wed, 21 Dec 2011 17:58:02 GMT)
Full text and
rfc822 format available.
Acknowledgement sent
to
RANJITH REDDY KOMANLA <ranjithreddyis <at> gmail.com>
:
New bug report received and forwarded. Copy sent to
bug-coreutils <at> gnu.org
.
(Wed, 21 Dec 2011 17:58:02 GMT)
Full text and
rfc822 format available.
Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):
Hello ,
Here is my case .
pwd : /test
ls -l : Nothing within the directory !!
But when i tried using -----> dirname xyz
it gave output as <.> { output states , present directory ,but there
is not such filename/directory present within my test1 directory }
If it had stated no such directory ,it would have served my purpose .
Ignore : If i'm wrong or this bug is already cured .
When i tried using the option dirname
Regards
Ranjith Reddy Komanla
816-265-1232
Added tag(s) notabug.
Request was from
Eric Blake <eblake <at> redhat.com>
to
control <at> debbugs.gnu.org
.
(Wed, 21 Dec 2011 18:09:02 GMT)
Full text and
rfc822 format available.
Reply sent
to
Eric Blake <eblake <at> redhat.com>
:
You have taken responsibility.
(Wed, 21 Dec 2011 18:09:02 GMT)
Full text and
rfc822 format available.
Notification sent
to
RANJITH REDDY KOMANLA <ranjithreddyis <at> gmail.com>
:
bug acknowledged by developer.
(Wed, 21 Dec 2011 18:09:02 GMT)
Full text and
rfc822 format available.
Message #12 received at 10342-done <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
tag 10342 notabug
thanks
On 12/21/2011 09:27 AM, RANJITH REDDY KOMANLA wrote:
> ls -l : Nothing within the directory !!
> But when i tried using -----> dirname xyz
> it gave output as <.> { output states , present directory
This is the correct behavior. It is required by POSIX - dirname is a
completely textual operation that pays no attention to what exists or
does not exist in your file system, and the dirname of a string that
resembles a relative file name is the string '.' (the current directory
is the correct dirname of a relative file name, if that relative name
was indeed a file; but the algorithm works even if there is no file by
that name).
http://pubs.opengroup.org/onlinepubs/9699919799/utilities/dirname.html
I'm closing this bug report, as there is no bug here. However, feel
free to make further comments if you need more clarification, or help in
determining if 'dirname' really is the best fit for the shell scripting
task you were really attempting to solve.
--
Eric Blake eblake <at> redhat.com +1-919-301-3266
Libvirt virtualization library http://libvirt.org
[signature.asc (application/pgp-signature, attachment)]
Message #13 received at 10342-done <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
On 12/21/2011 11:06 AM, Eric Blake wrote:
>> But when i tried using -----> dirname xyz
>> it gave output as <.> { output states , present directory
>
> http://pubs.opengroup.org/onlinepubs/9699919799/utilities/dirname.html
>
> I'm closing this bug report, as there is no bug here. However, feel
> free to make further comments if you need more clarification, or help in
> determining if 'dirname' really is the best fit for the shell scripting
> task you were really attempting to solve.
>> If it had stated no such directory ,it would have served my purpose .
Preemptively, I'm going to guess what you were trying to do (but of
course, stating your actual goal will get you further if my guess is on
the wrong track) - given an arbitrary string in $str, determine whether
that string represents an existing file; if so, report the absolute path
of the directory that contains the file, and if not, report that no such
file exists.
In which case, this will do the trick (using GNU readlink):
readlink -ve -- "$str" || dirname -- "$(readlink -e -- "$str")"
It is also possible to do this without forking readlink or dirname, but
instead doing it entirely in POSIX shell using constructs like ${str%/*}
and test -f. Making it portable to Solaris /bin/sh is tougher.
--
Eric Blake eblake <at> redhat.com +1-919-301-3266
Libvirt virtualization library http://libvirt.org
[signature.asc (application/pgp-signature, attachment)]
bug archived.
Request was from
Debbugs Internal Request <help-debbugs <at> gnu.org>
to
internal_control <at> debbugs.gnu.org
.
(Thu, 19 Jan 2012 12:24:04 GMT)
Full text and
rfc822 format available.
This bug report was last modified 13 years and 150 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.