Go Back   The macosxhints Forums > OS X Help Requests > UNIX - Newcomers



Reply
 
Thread Tools Rate Thread Display Modes
Old 10-01-2002, 10:32 PM   #21
hayne
Site Admin
 
Join Date: Jan 2002
Location: Montreal
Posts: 32,473
try using full paths only

I can't help but think we are getting confused here by the use of relative paths and the use of ~ in pathnames. Could we please try everything again, using only full path names (starting with a slash)?
E.g. one thing that is strange is that your '/usr/bin/which' command seems to be using the ~ in its output - mine does not.
So please try the following in a tcsh shell and report back on the results. (Don't type in the commands - just copy and paste them into the Terminal all at once, then copy & paste the results back into a Reply here.):

echo $SHELL
setenv PATH "/Users/mikewhitlaw/bin2:/Users/mikewhitlaw/bin:/usr/local/bin:/bin:/sbin:/usr/bin:/usr/sbin"
echo $PATH
cd
pwd
ls -ld ..
ls -ld .
ls -ld bin
ls -ld bin2
ls -l bin/tester
ls -l bin2/ls
ls bin/tester | wc
ls bin/ls | wc
which which
which tester
which ls
/usr/bin/which tester
/usr/bin/which ls
echo "That's all ..."
hayne is offline   Reply With Quote
Old 10-01-2002, 10:39 PM   #22
windlaser
Prospect
 
Join Date: Sep 2002
Posts: 11
progress!

Now this is just figgin wierd: I changed my .login from:

setenv PATH "~/bin:/usr/local/bin:$PATH"

to an explicit

setenv PATH "/users/mikewhitlaw/bin:/usr/local/bin:$PATH"

and it worked! After doing this I noticed the lower case u in /users and thought it curious that this worked. So I changed it to:

setenv PATH "/Users/mikewhitlaw/bin:/usr/local/bin:$PATH"

and that worked too!

It's only when I use:

setenv PATH "~/bin:/usr/local/bin:$PATH"

that it doesn't work.

So now I have two questions:
What's with Users and users being the same?
Why is ~/bin different from /Users/mikewhitlaw/bin?

And I know you'll want proof so:

Last login: Tue Oct 1 22:25:31 on ttyp1
Welcome to Darwin!
[foofy:~] mikewhitlaw% cat .login

setenv PATH "~/bin:/usr/local/bin:$PATH"
[foofy:~] mikewhitlaw% echo $PATH
/Users/mikewhitlaw/bin:/usr/local/bin:/bin:/sbin:/usr/bin:/usr/sbin
[foofy:~] mikewhitlaw% which tester
tester: Command not found.
[foofy:~] mikewhitlaw%

--- edit .login, close terminal, open terminal ---

Last login: Tue Oct 1 22:33:30 on ttyp1
Welcome to Darwin!
[foofy:~] mikewhitlaw% cat .login

setenv PATH "/users/mikewhitlaw/bin:/usr/local/bin:$PATH"
[foofy:~] mikewhitlaw% echo $PATH
/users/mikewhitlaw/bin:/usr/local/bin:/bin:/sbin:/usr/bin:/usr/sbin
[foofy:~] mikewhitlaw% which tester
/users/mikewhitlaw/bin/tester
[foofy:~] mikewhitlaw%

--- edit .login, close terminal, open terminal ---

Last login: Tue Oct 1 22:35:13 on ttyp1
Welcome to Darwin!
[foofy:~] mikewhitlaw% cat .login

setenv PATH "/Users/mikewhitlaw/bin:/usr/local/bin:$PATH"
[foofy:~] mikewhitlaw% echo $PATH
/Users/mikewhitlaw/bin:/usr/local/bin:/bin:/sbin:/usr/bin:/usr/sbin
[foofy:~] mikewhitlaw% which tester
/Users/mikewhitlaw/bin/tester
[foofy:~] mikewhitlaw%


wadaya think?
windlaser is offline   Reply With Quote
Old 10-01-2002, 10:49 PM   #23
mervTormel
League Commissioner
 
Join Date: Jan 2002
Posts: 5,536
hmm, you dint actually run tester so i'm thinking your testing is incomplete

odd that your ~ isn't expanded to your home dir in that respect. but, i'm glad it's over. mostly.

keep diggin'

thanks to hayne for subdividing this nut into its subatomic particles.
__________________
On a clear disk, you can seek forever.
mervTormel is offline   Reply With Quote
Old 10-01-2002, 10:50 PM   #24
pmccann
Major Leaguer
 
Join Date: Jan 2002
Location: Adelaide, South Australia
Posts: 470
Aah, you guys: it's just that ~ expansion doesn't work to work correctly in setenv calls, so they should always be explicit paths.

The problem is that ~ expansion only works correctly if the ~ is the first character of a word. So even if you have to add a quote mark to the beginning of a setenv call (as per some of the examples above) it'll undermine your expectations.

Funky, but documented in "man tcsh".

Sorry being late to the party on this one: I'm sure you all enjoyed the ride!

Cheers,
Paul

Last edited by pmccann; 10-02-2002 at 09:32 PM.
pmccann is offline   Reply With Quote
Old 10-01-2002, 10:57 PM   #25
Titanium Man
Guest
 
Posts: n/a
Paul, you're a genius. This has been an entertaining thread.
  Reply With Quote
Old 10-01-2002, 11:26 PM   #26
hayne
Site Admin
 
Join Date: Jan 2002
Location: Montreal
Posts: 32,473
Two answers

Quote:
windlaser wrote:
So now I have two questions:
What's with Users and users being the same?
Why is ~/bin different from /Users/mikewhitlaw/bin?

1) The OS X filesystem (HFS+) is case-preserving but case-insensitive. So it keeps whatever case you use for filenames but it doesn't distinguish Foo from FOO from foo. (or Users from users).
2) As pointed out above by pmccann, the shell does the conversion from ~ to the full path only in certain cases. Here's the relevant extract from 'man tcsh':
Quote:
The character `~' at the beginning of a filename refers to
home directories. Standing alone, i.e., `~', it expands
to the invoker's home directory as reflected in the value
of the home shell variable. When followed by a name con-
sisting of letters, digits and `-' characters the shell
searches for a user with that name and substitutes their
home directory; thus `~ken' might expand to `/usr/ken' and
`~ken/chmach' to `/usr/ken/chmach'. If the character `~'
is followed by a character other than a letter or `/' or
appears elsewhere than at the beginning of a word, it is
left undisturbed. A command like `setenv MANPATH
/usr/man:/usr/local/man:~/lib/man' does not, therefore, do
home directory substitution as one might hope.

hayne is offline   Reply With Quote
Old 10-01-2002, 11:36 PM   #27
windlaser
Prospect
 
Join Date: Sep 2002
Posts: 11
Thanks to all

This has been a big help. My faith has been restored...
windlaser is offline   Reply With Quote
Old 10-02-2002, 08:40 AM   #28
stetner
MVP
 
Join Date: Jan 2002
Location: Brisbane, Australia
Posts: 1,108
And I have been given another reason to avoid 'csh' type shells like the plague!

sh or ksh for me.
__________________
Douglas G. Stetner
UNIX Live Free Or Die
stetner is offline   Reply With Quote
Old 10-02-2002, 09:45 PM   #29
pmccann
Major Leaguer
 
Join Date: Jan 2002
Location: Adelaide, South Australia
Posts: 470
Hey Doug,

come to where the flavour is: zsh country. It's been nothing short of smile-inducing in the time I've been using it (and should prove eminently comfortable for a ksh'er).

You know you want to.

Cheers,
Paul

ps Jaguar includes zsh 4.04, which is not too old. (4.05 seems to have been released in Aug 2002, a bit late for 10.2)
pmccann is offline   Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump



All times are GMT -5. The time now is 06:16 PM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.
Site design © IDG Consumer & SMB; individuals retain copyright of their postings
but consent to the possible use of their material in other areas of IDG Consumer & SMB.