Spaces in Csh Paths

Is it possible to safely maintain directory names with spaces in a csh
path? This works;

set path = ( /bin /home/space\ bin )

However if a later script tries to add to it;

set path = ( $path /usr/bin )

then the real escaped space is lost, since the set command expands the
$path variable (which is an array) into a flat space-separated string,
then reconstructs it into an array. I know the env variable $PATH,
which is colon-separated, could be used instead (since the csh keeps
$path and $PATH in sync);

setenv PATH "/bin:/home/space\ bin"
setenv PATH "${PATH}:/usr/bin"

but this just shifts the problem to directory names that contain
colons (admittedly much less likely).

Is there a reliable way to set the path to ensure the current contents
are never mangled, or is this just a limitation of the csh?
rodney.longhurst [ Fr, 18 April 2008 05:33 ] [ ID #1945021 ]

Re: Spaces in Csh Paths

rodney.longhurst [at] gmail.com writes:

> Is it possible to safely maintain directory names with spaces in a csh
> path? This works;
>
> set path = ( /bin /home/space\ bin )
>
> However if a later script tries to add to it;
>
> set path = ( $path /usr/bin )

You probably need to use
set path = ( $path:q /usr/bin )

> Is there a reliable way to set the path to ensure the current contents
> are never mangled, or is this just a limitation of the csh?

It's one of many... :-)
Maxwell Lol [ Fr, 18 April 2008 12:52 ] [ ID #1945037 ]

Re: Spaces in Csh Paths

Maxwell Lol <nos... [at] com.invalid> wrote:

> You probably need to use
> setpath= ( $path:q /usr/bin )

Yep, that works perfectly. Thanks very much.
rodney.longhurst [ So, 20 April 2008 15:56 ] [ ID #1946140 ]
Linux » comp.unix.shell » Spaces in Csh Paths

Vorheriges Thema: Shell audio oscilloscope journey
Nächstes Thema: How to match two key words in a paragraph