Re: Korn and csh variables issue
- From: Bruce Barnett <spamhater113+U060613071830@xxxxxxxxxxxx>
- Date: Tue, 13 Jun 2006 11:33:56 +0000 (UTC)
nishant80@xxxxxxxxx writes:
Is there a common way of defining a variable that will work in both
korn shell and C shell?
Well.... You could define them as environment variables, and THEN execute the shell.
for instance, this is done in /etc/profile, which is executed before the login shell.
I need to have a common way because I am using a separate file to
define some variables that will be used by multiple korn and csh
scripts.
I'd suggest you create two files
file.ksh
file.csh
and for ksh, execute
. file.ksh
for csh, execute
source file.csh
As another suggestion, you can create an alias or function. For
instance, in csh, you can use
alias setvar 'set \!:1 = \!:2'
and for ksh/bash you can define a function:
setvar() {
eval $1=$2
}
then the command
setvar a 123
would work for both.
But, IMHO, if you can do that, then you might as well define the
variables at the same time.
NOTE: This is not an environment variable. That would require the following modifications:
#csh
alias setvar 'setenv \!:1 \!:2'
#ksh
setvar() {
eval export $1=$2
}
--
Sending unsolicited commercial e-mail to this account incurs a fee of
$500 per message, and acknowledges the legality of this contract.
.
- References:
- Korn and csh variables issue
- From: nishant80
- Korn and csh variables issue
- Prev by Date: Re: Variable in while loop not returning value outside the loop.?
- Next by Date: Re: Korn and csh variables issue
- Previous by thread: Re: Korn and csh variables issue
- Next by thread: Re: Korn and csh variables issue
- Index(es):
Relevant Pages
|
Loading