Hello,  
  
> --- Ursprüngliche Nachricht ---  
...  
>   
> That's how the script is right now.  I thought it would be nice to use  
> a few extra features of bash, changed the first line and found this  
> "change of directory" problem...  I thought it was funny, since in the  
> Linux machines (where I had that problem) /bin/sh is a link to  
> /bin/bash, so I was expecting to see no difference with the change...  
>   
  
/bin/sh exists for compatability with the legacy Bourne shell and does 
not provide bash-specific features. In APP 1 I had a ~bash_cmd_rc file 
with some output in the BASH_ENV, and it is ignored by /bin/sh, even 
if /bin/sh is a softlink to /bin/bash on my machine. 
 
Having a softlink or several softlinks to the same executable is quite a 
common pattern in Unix. Every binary can read the name under which it was 
executed and make decisions on that. You can also use that in 
shellscripts (APP 2) where the $0 contains the name of the script. 
 
Regards, 
Roland 
 
 
APP 1: 
===== 
[EMAIL PROTECTED]:/usr/local/home/roland_NEW$ BASH_ENV=~/.bash_cmd_rc bash  
-c 'echo MMMMMMMMMMMMMMMM'  
bash called ...  
UID        PID  PPID  C STIME TTY          TIME CMD  
roland    9658  9627  0 Jan05 pts/6    00:00:00 /bin/bash  
roland   10411  9658  0 00:22 pts/6    00:00:00 bash -c echo  
MMMMMMMMMMMMMMMM  
roland   10412 10411  0 00:22 pts/6    00:00:00 ps -f  
MMMMMMMMMMMMMMMM  
[EMAIL PROTECTED]:/usr/local/home/roland_NEW$ BASH_ENV=~/.bash_cmd_rc sh -c  
'echo MMMMMMMMMMMMMMMM'  
MMMMMMMMMMMMMMMM  
  
APP 2: 
===== 
foo.sh: 
#!/bin/sh 
 
echo I was invoked as $0 
 
if [ `basename $0` == "a" ] 
then 
      echo AAAAAAAAAAAAAAAAAAAA 
elsif [ `basename $0` == "b" ] 
      echo BBBBBBBBBBBBBBBBBBBBBBBBB 
else 
      echo Dont know 
fi 
  
$ ln -s foo.sh a 
$ ln -s foo.sh b 
 
[EMAIL PROTECTED]:/usr/local/home/roland_NEW$ ./a 
I was invoked as ./a 
AAAAAAAAAAAAAAAAAAAA 
[EMAIL PROTECTED]:/usr/local/home/roland_NEW$ ./b 
I was invoked as ./b 
BBBBBBBBBBBBBBBBBBBBBBBBB 
 
> Thanks!  
>   
> Luis  
>   
  

-- 
Lust, ein paar Euro nebenbei zu verdienen? Ohne Kosten, ohne Risiko!
Satte Provisionen für GMX Partner: http://www.gmx.net/de/go/partner


-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED] 
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]

Reply via email to