I was under the (perhaps mistaken) impression that "source" does work in 
bash.

I have had "source /sw/bin/init.sh" in my ~/.bashrc since I started 
playing with Fink and the $PATH has always appropriately included the 
directories that /sw/bin/init.sh adds to it.

And I checked the man page for bash:
source filename [arguments]
               Read and execute commands from filename in the cur-
               rent shell environment and return the  exit  status
               of  the  last  command  executed from filename.  If
               filename does not contain a slash,  file  names  in
               PATH  are  used  to  find  the directory containing
               filename.  The file searched for in PATH  need  not
               be executable.  When bash is not in posix mode, the
               current directory is searched if no file  is  found
               in  PATH.   If  the  sourcepath option to the shopt
               builtin command is turned  off,  the  PATH  is  not
               searched.   If  any  arguments  are  supplied, they
               become the positional parameters when  filename  is
               executed.   Otherwise the positional parameters are
               unchanged.  The return status is the status of  the
               last command exited within the script (0 if no com-
               mands are executed), and false if filename  is  not
               found or cannot be read.

I could be wrong, but I thought that the only difference between "." 
(dot) and "source", as far as the bash shell is concerned, has to do 
with the inheritance of environment variables from one subshell to the 
next.  Like I said I could be wrong, though, that's just what I think I 
read somewhere.  I use "source" because it's a tiny bit more legible.

Should I switch all of my shell scripts to use "." instead?


Erik



On Friday, January 25, 2002, at 11:29  AM, Paul Lieberman wrote:

> Erik,
>  Never mind all that. If you're using bash then you can't "source
> /sw/bin/init.sh". source is a c shell function. The equivilent in bourne
> shell is a period. So what you want is
> . /sw/bin/init.sh
>
> Paul
>
>>>> Erik Price <[EMAIL PROTECTED]> 01/24/02 20:25 PM >>>
> Paul,
>
> Thank you, but yes, I use /sw/bin/bash as my default shell, though.  But
>
> there is something related:
>
> I noticed that whenever I execute /usr/bin/which and it fails to find
> the file, it would say "no foo in /sw/bin /sw/sbin /sw/bin /sw/sbin
> /usr/bin /bin /Users/eprice/bin (etc)".  But whenever I did "echo
> $PATH", the output was as expected:  /sw/bin /sw/sbin /usr/bin /bin
> /Users/eprice/bin (etc)".
>
> Note that "which" is checking /sw/bin and /sw/sbin twice for the file,
> according to this error message.  So, reading the man page, I discovered
>
> that /usr/bin/which checks the .cshrc file for $PATH information.  I
> thought this was strange, that /usr/bin/which would be so shell-specific
>
> like that (don't most utilities just check for a standard environment
> variable, like $PATH ?).  This led me to take a look in my .cshrc.
>
> I haven't used my .cshrc since I first installed Fink, because of course
>
> why use tcsh when you can have bash?  But that's beside the point.  It
> turns out that I still had "source /sw/bin/init.csh" in my .cshrc file.
>
> Because of this, I suspect that /usr/bin/which was checking the .cshrc,
> finding the reference to /sw/bin/init.csh, and executing it somehow, in
> effect causing /sw/bin and /sw/sbin to be searched TWICE.
>
> I don't know much about how the /usr/bin/which utility works, but I
> thought that this was interesting -- for those of you who have switched
> to another shell as your default, but still have a ".cshrc" file sitting
>
> in your home directory, you may wish to rename it or comment out the
> "source /sw/bin/init.csh".  It doesn't do any harm to have
> /usr/bin/which search through /sw/bin and /sw/sbin twice but if you're
> OCD like I am then that kind of thing bothers you and you probably want
> to do something about it.
>
> On the flip side, I still haven't figured out what may have taken
> /usr/sbin and /sbin out of my default $PATH.  I checked the Fink init
> script that I use (I source /sw/bin/init.sh from my ~/.bash_profile),
> and that doesn't have any effect.  But on the other hand, I don't recall
>
> EVER manually changing my $PATH variable or running any other system
> startup scripts that do.  What file is used by Darwin as the equivalent
> of /etc/profile (for system-wide default shell configuration)?
>
>
> Cheers,
> Erik
>
> PS: Paul, hope you don't mind I 'listed' this response, I thought others
>
> could benefit.
>
>
> On Thursday, January 24, 2002, at 11:12  AM, Paul Lieberman wrote:
>
>> Erik,
>>  That would be a problem. If your shell is the default tcsh then you
>> want to
>> source /sw/bin/init.csh
>>   init.sh is for bash, sh or other Bourne shells.
>>
>> Paul
>
>
>
> _______________________________________________
> Fink-beginners mailing list
> [EMAIL PROTECTED]
> https://lists.sourceforge.net/lists/listinfo/fink-beginners
>


_______________________________________________
Fink-beginners mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/fink-beginners

Reply via email to