Newsgroups: comp.unix.shell Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!wuarchive!m.cs.uiuc.edu!ux1.cso.uiuc.edu!uxa.cso.uiuc.edu!jbn35564 From: jbn35564@uxa.cso.uiuc.edu (J.B. Nicholson) Subject: How to force usage of global vars in KSH? Message-ID: <1991Apr18.235718.14785@ux1.cso.uiuc.edu> Summary: How do I force usage of an already defined var or a var I want to make global in KSH? Keywords: global vars KSH force usage Sender: usenet@ux1.cso.uiuc.edu (News) Reply-To: jeffo@uiuc.edu Organization: University of Illinois at Urbana Date: Thu, 18 Apr 1991 23:57:18 GMT Lines: 37 How do I force usage of an already defined var or a var I want to make global in KSH? I've got a function that has a number of local variables all made local with typeset, but there is one variable that may already exist in the calling shell, or may not. Either way, I want this variable, $PATHHIST, to be global. When I access it, it seems to be able to read the existing value of the variable, but not able to modify and have it so the calling shell gets the modified value. To make the above happen, I was using: PATHHIST=${PATHHIST}'value' where "export PATHHIST='before'" was given to the calling shell. Also, the trace of the program seems to show the correct value for $PATHHIST, but when the function exits, I am left with the value of $PATHHIST that I started the function with; totally unmodified. When I use "typeset -x PATHHIST" and then do the line above, a local variable (that I would assume is visible to child shells) seems to be made because the trace of the function shows that $PATHHIST has a value of 'value' and not 'beforevalue'. Thanks. Jeff -- +----------------------------------------------------------------------------+ | "If you hear an onion ring - answer it." J.B. Nicholson | +----------------------------------------------------------------------------+ | jeffo@uiuc.edu (Internet) These opinions are mine, that's all.| +----------------------------------------------------------------------------+