Hi, I recently realised that the dirname-program from the coreutils-5.2.1-23.8 - package doesn't take ".." and "." as Parent-Directory or Current-Directory and because of that I decided to write a similar program in Perl that does the same task as dirname but with some more features. To show you what I don't like about the original dirname I'll give you some examples:
[EMAIL PROTECTED]:~> dirname ../testfile .. [EMAIL PROTECTED]:~> dirname-ng.pl ../testfile /home [EMAIL PROTECTED]:~> As you can see my version of the program interprets the ".." as parent directory and "." as current directory and always returns the absolute path to the user. My version also doesn't allow going "over" root-directory. Like this example: [EMAIL PROTECTED]:~> dirname ../../../././testfile ../../.././. [EMAIL PROTECTED]:~> dirname-ng.pl ../../../././testfile / [EMAIL PROTECTED]:~> There was also another thing I didn't like about this version: You can't work with file-lists. dirname always needs ONE path to work. I also "fixed" this issue. My version can work with many files. An example to show you what I mean: [EMAIL PROTECTED]:~> dirname ../testfile /tmp/testfile2 dirname: too many arguments Try `dirname --help' for more information. [EMAIL PROTECTED]:~> dirname-ng.pl ../testfile /tmp/testfile2 /home /tmp [EMAIL PROTECTED]:~> and another example: [EMAIL PROTECTED]:~> find /tmp/test/* | dirname | sort | uniq dirname: too few arguments Try `dirname --help' for more information. [EMAIL PROTECTED]:~> find /tmp/test/* | dirname-ng.pl - | sort | uniq /tmp/test /tmp/test/a /tmp/test/b /tmp/test/c /tmp/test/d [EMAIL PROTECTED]:~> find /tmp/test/* /tmp/test/a /tmp/test/a/testfile /tmp/test/b /tmp/test/b/testfile /tmp/test/c /tmp/test/c/testfile /tmp/test/d /tmp/test/d/testfile [EMAIL PROTECTED]:~> As you can see here, my version can also handle input from STDIN with the "-" parameter. I don't think the issues I listed are "real" bugs, but lack of features. Maybe you think about implementing some of these features in futures releases. I append my version of the program. Feel free to modify and change the sourcecode if you like to. It's public domain. <<dirname-ng.pl>> Have a nice day :) Mit freundlichen Grüßen / Best regards Manuel Fill IT Rechenzentrum UNIX-Basis Fritz Egger GmbH & Co. Holzwerkstoffe Weiberndorf 20 A-6380 St. Johann in Tirol Tel: +43 (0) 50600-10389 Fax: +43 (0) 50600-90389 e-mail: mailto:[EMAIL PROTECTED] Internet: http://www.egger.com
dirname-ng.pl
Description: dirname-ng.pl
_______________________________________________ Bug-coreutils mailing list [email protected] http://lists.gnu.org/mailman/listinfo/bug-coreutils
