Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

exporting a variable out of a function so the rest of the script can s

Status
Not open for further replies.

DanNJ

MIS
Mar 19, 2003
29
0
0
US
Why won't this work? How can I make it work?

Start Script:
a1()(
var=2; export var
)
echo $var
 
First Problem: Functions are defined curly braces, not parentheses, as shown below

a1() {
var=2; export var
}

Second Problem: You never actually call the function so the variable never gets set.
 
I forgot to call it when I typed it here, it seems that () keep the variables within the function but {} let them out.

interesting.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top