Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

what does csh search

33 views
Skip to first unread message

fpefpe

unread,
Feb 3, 2016, 2:20:53 PM2/3/16
to
Hello -- does the csh (tcsh) searh $path or $PATH looking for command?

Barry Margolin

unread,
Feb 3, 2016, 3:23:09 PM2/3/16
to
In article <8b4c2db4-0122-41bc...@googlegroups.com>,
fpefpe <fpesp...@gmail.com> wrote:

> Hello -- does the csh (tcsh) searh $path or $PATH looking for command?

Since setting one automatically sets the other to the equivalent value
($path is a list, $PATH is a colon-delimited string), what difference
does it make?

--
Barry Margolin, bar...@alum.mit.edu
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***

fpefpe

unread,
Feb 3, 2016, 4:52:08 PM2/3/16
to
Hello -- thanks for the post --

I use tcsh via cygwin/windows -- since $path has the ":" removed, it seems
that the result in $path could be be ambiguous if some of directories could have been in the form ...:/c/program files/foo:... with the ":" removed how does the "scanner" know where the directory starts and ends?


Rakesh Sharma

unread,
Feb 4, 2016, 4:49:35 AM2/4/16
to
On Thursday, 4 February 2016 03:22:08 UTC+5:30, fpefpe wrote:
>
> I use tcsh via cygwin/windows -- since $path has the ":" removed, it seems
> that the result in $path could be be ambiguous if some of directories could have been in the form ...:/c/program files/foo:... with the ":" removed how does the "scanner" know where the directory starts and ends?
>

csh looks at the $path (lowercase & a csh shell variable) while searching for directories.

$path <=> $PATH transformation is symmetric normally, till we have directories with colons in their names, that's why you would not notice the difference.

Observe the following:
#!/bin/csh
1. set d = "/tmp/a:b"
1. mkdir -p "$d";
2. echo 'echo "Hello, world! from <$0>"' > $d/hello.sh
3. chmod +x "$d/hello.sh"
4. set path = ( $path:q "$d" )
5. echo "PATH=[$PATH]"
6. hello.sh
########

# case-A: path -> PATH
This run successfully in the case of setting the $path first
and cshell autogenerates internally the value of $PATH.

# case-B: PATH -> path
Now change line numbers 4 and 5 to :
setenv PATH "${PATH}:${d}"
echo "$path=[$path]"
Now we reverse the process, and set the $PATH first then let
cshell autogenerate internally the value of $path
You will observe that csh stumbles and converts "a:b" => "a" "b"
that is two directories in place one, since it doesn't know that the
colon (:) in the directory name is a path separator or part of name.
Note, it didn't have any such problem in the path -> PATH conversion.

Hence, (and in the unlikely possibility) that directories "a" and "b"
don't already exist, no preceding dirs contain helo.sh, and "a" or "b"
also don't contain "hello.sh" executable (which can be
anything even a gateway to external intruders) you should see the
re-assuring message that the command hello.sh not found.

This proves that files are searched in the directories specified in $path
(the lowercase path) and not the uppercase $PATH.

To convince yourself, case-B can even written as:
csh -c 'hello.sh' # THIS should give an error that hello.sh command not found
since in this the csh -c '..' inherits the PATH env first, then transforms
that to a lowercase path , and erroneously.
Q.E.D.
-Rakesh

Kaz Kylheku

unread,
Feb 4, 2016, 10:39:58 PM2/4/16
to
On 2016-02-03, fpefpe <fpesp...@gmail.com> wrote:
> Hello -- does the csh (tcsh) searh $path or $PATH looking for command?

Csh searches for souls that stray from the path.

a...@google.com

unread,
Feb 5, 2016, 11:41:00 AM2/5/16
to
Made me laugh, my organisation mandates use of csh for reasons lost in
the mist of time and now we've got huge amounts of it and so we carry
on down that path as we don't want two standards. What's annoying is
when they fix bugs in the implementation and break our scripts which are
accidentally reliant on the buggy behaviour..

Janis Papanagnou

unread,
Feb 5, 2016, 12:19:32 PM2/5/16
to
Speaking of "standards" in case of csh is something I'd be tempted to laugh
about, but instead I'm just wondering what folks who say so are thinking.
It's probably the same misconception that make some people talk about "the"
*.doc format being a [quasi-]"standard".

Janis

Kaz Kylheku

unread,
Feb 7, 2016, 8:50:31 AM2/7/16
to
On 2016-02-05, a...@google.com <a...@google.com> wrote:
> On 05/02/2016 03:39, Kaz Kylheku wrote:
>> On 2016-02-03, fpefpe <fpesp...@gmail.com> wrote:
>>> Hello -- does the csh (tcsh) searh $path or $PATH looking for command?
>>
>> Csh searches for souls that stray from the path.
>>
> Made me laugh, my organisation mandates use of csh for reasons lost in
> the mist of time

It is the organization that is lost in the mist of time. (Thus, so are
its reasons). But it is just a charade played during office hours.
Come lunch break or the commute home, you all whip out the smartphones and
tabs.
0 new messages