It is currently Tue, 30 Nov 2021 18:05:17 GMT

Author Message
 Bourne shell script affecting current shell with arguments
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 "":

export VALUE

When the user executes " 3", the parameter 3 is seen.  However, when
the user executes ". 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.

Greg Jewell

 Sun, 09 Oct 2005 23:45:47 GMT   
 Bourne shell script affecting current shell with arguments

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,
Genuity Managed Services, a Level(3) Company, Woburn, MA
Please DON'T copy followups to me -- I'll assume it wasn't posted to the group.

 Mon, 10 Oct 2005 01:12:37 GMT   
   [ 2 post ] 

Similar Threads

1. Problems with Arguments in Bourne Shell Scripts

2. bourne shell script command line argument

3. passing arguments with spaces in Bourne shell script

4. Bourne shell script to determine users shell

5. Light Speed Bourne Shell! (was: Bourne shell tricks)

6. For FAQ: Trick to have changes affect the current shell

7. Bourne Shell compatible shells (was: Request: which shells)

8. A Solaris 8 (Bourne Shell) Scripting question, regarding a log rotation script

9. help in learning how to do Bourne shell scripts then converting them to csh scripts

10. Getting the 10th argument in Bourne shell

Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software