From unknown Sun Jun 15 08:03:27 2025 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-Mailer: MIME-tools 5.509 (Entity 5.509) Content-Type: text/plain; charset=utf-8 From: bug#10342 <10342@debbugs.gnu.org> To: bug#10342 <10342@debbugs.gnu.org> Subject: Status: Bug Report for command "dirname" Reply-To: bug#10342 <10342@debbugs.gnu.org> Date: Sun, 15 Jun 2025 15:03:27 +0000 retitle 10342 Bug Report for command "dirname" reassign 10342 coreutils submitter 10342 RANJITH REDDY KOMANLA severity 10342 normal tag 10342 notabug thanks From debbugs-submit-bounces@debbugs.gnu.org Wed Dec 21 12:57:45 2011 Received: (at submit) by debbugs.gnu.org; 21 Dec 2011 17:57:45 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1RdQQD-0003i1-G5 for submit@debbugs.gnu.org; Wed, 21 Dec 2011 12:57:45 -0500 Received: from eggs.gnu.org ([140.186.70.92]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1RdP3g-0001jb-5K for submit@debbugs.gnu.org; Wed, 21 Dec 2011 11:30:24 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RdP1Z-0007Em-G1 for submit@debbugs.gnu.org; Wed, 21 Dec 2011 11:28:19 -0500 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,FREEMAIL_FROM, RCVD_IN_DNSWL_LOW,T_DKIM_INVALID autolearn=unavailable version=3.3.2 Received: from lists.gnu.org ([140.186.70.17]:48403) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RdP1Z-0007Ei-EZ for submit@debbugs.gnu.org; Wed, 21 Dec 2011 11:28:13 -0500 Received: from eggs.gnu.org ([140.186.70.92]:34378) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RdP1T-0007Lo-SA for bug-coreutils@gnu.org; Wed, 21 Dec 2011 11:28:13 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RdP1I-0007AD-Q1 for bug-coreutils@gnu.org; Wed, 21 Dec 2011 11:28:07 -0500 Received: from mail-gy0-f169.google.com ([209.85.160.169]:41789) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RdP1I-00079d-Mp for bug-coreutils@gnu.org; Wed, 21 Dec 2011 11:27:56 -0500 Received: by ghrr18 with SMTP id r18so5420539ghr.0 for ; Wed, 21 Dec 2011 08:27:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:date:message-id:subject:from:to:content-type; bh=gW2nI5xMbvwvE+fgBEmR9XRFQL0nrM4DRfyOxyeJtkA=; b=Oy3oQd7+dKp+6bxpehu3NNdgS106lLK5XDDkFHHWSBCSNjboEcAWXelBJRqCBDHmzg ocE7I8d3N6mRUdEa+qR7L1wzR3869KQtnfkigYYFhQp+HVUq2q18Zu3cprIQMnq/7G7+ cJqQZquLDsauOBZKLSokQ8L4LHxWKEkXeMaj4= MIME-Version: 1.0 Received: by 10.50.187.226 with SMTP id fv2mr4264702igc.20.1324484875224; Wed, 21 Dec 2011 08:27:55 -0800 (PST) Received: by 10.50.242.66 with HTTP; Wed, 21 Dec 2011 08:27:55 -0800 (PST) Date: Wed, 21 Dec 2011 11:27:55 -0500 Message-ID: Subject: Bug Report for command "dirname" From: RANJITH REDDY KOMANLA To: bug-coreutils@gnu.org Content-Type: text/plain; charset=ISO-8859-1 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-Received-From: 140.186.70.17 X-Spam-Score: -5.9 (-----) X-Debbugs-Envelope-To: submit X-Mailman-Approved-At: Wed, 21 Dec 2011 12:57:45 -0500 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -5.9 (-----) 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 From debbugs-submit-bounces@debbugs.gnu.org Wed Dec 21 13:08:40 2011 Received: (at control) by debbugs.gnu.org; 21 Dec 2011 18:08:40 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1RdQam-0003xj-16 for submit@debbugs.gnu.org; Wed, 21 Dec 2011 13:08:40 -0500 Received: from mx1.redhat.com ([209.132.183.28]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1RdQah-0003xU-BA; Wed, 21 Dec 2011 13:08:38 -0500 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id pBLI6TY1029591 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Wed, 21 Dec 2011 13:06:29 -0500 Received: from [10.3.113.42] (ovpn-113-42.phx2.redhat.com [10.3.113.42]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id pBLI6SO2005717; Wed, 21 Dec 2011 13:06:28 -0500 Message-ID: <4EF22023.9040008@redhat.com> Date: Wed, 21 Dec 2011 11:06:27 -0700 From: Eric Blake Organization: Red Hat User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:8.0) Gecko/20111115 Thunderbird/8.0 MIME-Version: 1.0 To: RANJITH REDDY KOMANLA Subject: Re: bug#10342: Bug Report for command "dirname" References: In-Reply-To: X-Enigmail-Version: 1.3.4 OpenPGP: url=http://people.redhat.com/eblake/eblake.gpg Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="------------enig1AE35848E04A4F419F15CD72" X-Scanned-By: MIMEDefang 2.67 on 10.5.11.11 X-Spam-Score: -10.3 (----------) X-Debbugs-Envelope-To: control Cc: 10342-done@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -10.3 (----------) This is an OpenPGP/MIME signed message (RFC 2440 and 3156) --------------enig1AE35848E04A4F419F15CD72 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable 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. --=20 Eric Blake eblake@redhat.com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --------------enig1AE35848E04A4F419F15CD72 Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.11 (GNU/Linux) Comment: Public key at http://people.redhat.com/eblake/eblake.gpg Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iQEcBAEBCAAGBQJO8iAkAAoJEKeha0olJ0NqmHIH/j8tx7Z6SEaQSowAIp/mH3S/ PaTZd3QX2BHzjAEQxrp4pXMEdW19vblLKQrlmYevdW/HuMObNkpEn0yBF0E3Uugl yEc0BQ6qSsLr0ncZBo1iau/uJxIRsYL86qvK/gRMh2Xwl+IS9CZac/Ijbzgpujxx 8dTExsmig0ynXK2IXaMwH2na3oJWA/vGLPpu6xbJEH+y+r1jQ2x0p9lHmdTbQYcy Wg7rTrb3xNp5DA1LDSn5Df0Ithdeq4FWjwe4LA0jHKXKXW8lofug1zrIoQyjfrDa 7FJ770lvkKNwo2H0CqWu8JRC6L6z+4M4VXz7LLQI6isu4TGVK65CyR9xE3mK180= =mSgZ -----END PGP SIGNATURE----- --------------enig1AE35848E04A4F419F15CD72-- From debbugs-submit-bounces@debbugs.gnu.org Wed Dec 21 13:40:48 2011 Received: (at 10342-done) by debbugs.gnu.org; 21 Dec 2011 18:40:48 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1RdR5r-0005QP-R9 for submit@debbugs.gnu.org; Wed, 21 Dec 2011 13:40:48 -0500 Received: from mx1.redhat.com ([209.132.183.28]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1RdR5n-0005QF-Fw for 10342-done@debbugs.gnu.org; Wed, 21 Dec 2011 13:40:46 -0500 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id pBLIcMN3020865 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Wed, 21 Dec 2011 13:38:37 -0500 Received: from [10.3.113.42] (ovpn-113-42.phx2.redhat.com [10.3.113.42]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id pBLIMS5i008745; Wed, 21 Dec 2011 13:22:28 -0500 Message-ID: <4EF223E4.6030603@redhat.com> Date: Wed, 21 Dec 2011 11:22:28 -0700 From: Eric Blake Organization: Red Hat User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:8.0) Gecko/20111115 Thunderbird/8.0 MIME-Version: 1.0 Subject: Re: bug#10342: Bug Report for command "dirname" References: <4EF22023.9040008@redhat.com> In-Reply-To: <4EF22023.9040008@redhat.com> X-Enigmail-Version: 1.3.4 OpenPGP: url=http://people.redhat.com/eblake/eblake.gpg Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="------------enig1B704A82851E0DA11112C51C" X-Scanned-By: MIMEDefang 2.67 on 10.5.11.11 X-Spam-Score: -9.7 (---------) X-Debbugs-Envelope-To: 10342-done Cc: RANJITH REDDY KOMANLA , 10342-done@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -9.7 (---------) This is an OpenPGP/MIME signed message (RFC 2440 and 3156) --------------enig1B704A82851E0DA11112C51C Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable 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 >=20 > http://pubs.opengroup.org/onlinepubs/9699919799/utilities/dirname.html >=20 > 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 i= n > 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. --=20 Eric Blake eblake@redhat.com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --------------enig1B704A82851E0DA11112C51C Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.11 (GNU/Linux) Comment: Public key at http://people.redhat.com/eblake/eblake.gpg Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iQEcBAEBCAAGBQJO8iPkAAoJEKeha0olJ0Nq1/wH/0x2SVx4ayb6zN5T7TRPAMGY 3VU5WfwWd9ICEbOHA0dmSgBCYrOjcJbgPeC+OKITUrxU+hZfZZRSOGXNC84Z4NKu hZmioGzWYmMTx7ZzvaTrSlyaNc1e+H2NMi7G4qdntTi6Du9or7z/+a4MshSxE/Hx 1iMo8GtJtNOsrfZfgsxagtYiVTNyVQMkRTAzT+5YT0lIMhGu058weulmPlxXwbzU dQ1fq+n3zR0aLr5X/GnSK9ap71QVtCXDJKtXpXBQldnQlDbnnqzMLx96iSeMUfYy U/ntHbSpuVZRcuTKhwex58+Y6p9rK66EKgAgHWBEeC15v5gPVUkW9jgs8b84cu8= =YtdR -----END PGP SIGNATURE----- --------------enig1B704A82851E0DA11112C51C-- From unknown Sun Jun 15 08:03:27 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Thu, 19 Jan 2012 12:24:04 +0000 User-Agent: Fakemail v42.6.9 # This is a fake control message. # # The action: # bug archived. thanks # This fakemail brought to you by your local debbugs # administrator