bug-coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: basename for directories containing space


From: Eric Blake
Subject: Re: basename for directories containing space
Date: Fri, 08 Sep 2006 01:35:34 +0000

> address@hidden NZ PostSep06]$ echo `pwd`
> /home/corrin/NZ PostSep06
> address@hidden NZ PostSep06]$ basename `pwd`
> NZ

You didn't quote this correctly, so you are effectively doing:
basename "/home/corrin/NZ" "PostSep06"

and since PostSep06 is not a suffix of NZ, basename is correctly
reporting "NZ" as the result.

Try 'basename "`pwd`"' instead, and read a good tutorial on
shell quoting.

> address@hidden NZ PostSep06]$ basename --version
> basename (GNU coreutils) 5.2.1

You are due for an upgrade.  The latest stable version of coreutils
is 5.97, and a beta release 6.1 is also available.  Cygwin has a good
up-to-date port of coreutils for window.

> But since this is exactly what basename is for... Plus my version doesn't 
> handle 
> directory names with slashes in them, if such a directory is ever legal (on 
> windows?)

Windows treats / and \ identically (although if you use the
cygwin port of coreutils for Windows, it is better to use /, because
the quoting issues with \ are tricky).

> Disclaimer: This email and any files transmitted with it are confidential and 
> may contain legally privileged material

It is a good idea to refrain from unenforceable legal disclaimers when
posting to a publicly archived mailing list.  If needs be, open a webmail
account that won't have a company disclaimer appended to it.

-- 
Eric Blake




reply via email to

[Prev in Thread] Current Thread [Next in Thread]