Re: Bourne shell script affecting current shell with arguments
From: Barry Margolin (barry.margolin@level3.com)
Date: 04/23/03
- Next message: Bill Marcum: "Re: File to variable"
- Previous message: Chris F.A. Johnson: "Re: File to variable"
- In reply to: Greg Jewell: "Bourne shell script affecting current shell with arguments"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] [ attachment ]
From: Barry Margolin <barry.margolin@level3.com> Date: Wed, 23 Apr 2003 17:12:37 GMT
In article <3ea6b022.0@news>, Greg Jewell <gjewell@cnnxn.com> wrote:
>Hi All,
>
>We've got a script that is run by users running the Bourne shell to set
>environment variables needed by their current shell. The user passes some
>arguments to this script for the variables to be set. A sample script
>called "test.sh":
>
>VALUE=$1
>export VALUE
>
>When the user executes "test.sh 3", the parameter 3 is seen. However, when
>the user executes ". test.sh 3", the parameter 3 is not seen. Is there a
>way to get this to work under the Bourne shell? When the current shell is
>either Korn or Bash, it works as desired.
No, I don't think Bourne shell provides a way to pass parameters when
sourcing a script. I have two suggestions:
1) Have the user set a variable before running the script, and the script
looks at the variable rather than a command-line parameter.
2) Have the script define a function that does the real work. The user
sources the script to define the function, and then invokes the function
with a parameter.
-- Barry Margolin, barry.margolin@level3.com Genuity Managed Services, a Level(3) Company, Woburn, MA *** DON'T SEND TECHNICAL QUESTIONS DIRECTLY TO ME, post them to newsgroups. Please DON'T copy followups to me -- I'll assume it wasn't posted to the group.
- Next message: Bill Marcum: "Re: File to variable"
- Previous message: Chris F.A. Johnson: "Re: File to variable"
- In reply to: Greg Jewell: "Bourne shell script affecting current shell with arguments"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] [ attachment ]
Relevant Pages
|