[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

RE: can't export from shell scripts



When you run a script, you get a new copy of the shell to run it.
The change to the environment happens for the new shell but not
for the parents environment.  Try using the source command, as in
	. shellscript
to see if that makes a difference.

jim

>----------
>From: 	Chris Evans[SMTP:C.Evans@sghms.ac.uk]
>Sent: 	Friday, August 07, 1998 12:05 PM
>To: 	debian-user@lists.debian.org
>Cc: 	The recipient's address is unknown.
>Subject: 	can't export from shell scripts
>
>I think I've got something very odd going on.  I can export variables 
>successfully from the prompt but not from shell scripts.  I.e. typing 
>   $    export silly=test
>shows silly=test in the environment but putting
>         export silly=test2
>in a shell script and executing it doesn't get any change into the 
>environment.  If I put 
>         echo $silly 
>in the shell script it shows up fine echoing test2 nicely but the 
>environment still doesn't change.
>
>Using declare -x to declare silly makes no difference.  Whether the 
>variable is already declared in the environment or not makes no 
>difference.  If I put export -p  in the shell script, the listing shows 
>silly as test2 as well as other variables already set prior to the 
>script but rerunning env afterward shows silly back to test (or 
>nothing if I've export -n to kill it off first!)
>
>Putting #!/bin/bash as first line of the script makes no difference.  
>(By the way, am I right in thinking this isn't necessary, that the 
>chmod to executable gets it executable script status and the first 
>line would only invoke a new shell process to execute the script?)
>
>This is running Hamm, bash shell under X through xdm, new install 
>of all that on twin 586 box with SMP=1
>
>As far as I can see, this is causing all sorts of downstream 
>problems like StarOffice failing with a segmentation fault 
>complaining its environment isn't setup correctly (damn right it isn't!)
>
>I'm baffled.  What am I missing?  What am I doing wrong?!
>
>
>
>Chris
>
>
>
>--  
>Unsubscribe?  mail -s unsubscribe debian-user-request@lists.debian.org <
>/dev/null
>
>


--  
Unsubscribe?  mail -s unsubscribe debian-user-request@lists.debian.org < /dev/null


Reply to: