Hello,
The following script one.sh calls second.sh using the '.' operator (in order to retain environment variables defined in second.sh)
After the execution of second.sh, the original command line arguments $1,etc are lost.
#!/usr/bin/ksh
# first.sh : call this script with arguments a,b,c,d,e
echo parm5 $5
# output is 'e'
one=$1
second.sh $one
echo parm5 $5
# output is 'e'
. second.sh $one
echo parm5 $5
# output is blank
#!/usr/bin/ksh
# second.sh : this script is called by first.sh
echo second shell $1
How can we avoid this problem ? (Saving the arguments in additional variables $p1, $p2, ... would work, but I don't like this solution)
Best regards,
Luc
The following script one.sh calls second.sh using the '.' operator (in order to retain environment variables defined in second.sh)
After the execution of second.sh, the original command line arguments $1,etc are lost.
#!/usr/bin/ksh
# first.sh : call this script with arguments a,b,c,d,e
echo parm5 $5
# output is 'e'
one=$1
second.sh $one
echo parm5 $5
# output is 'e'
. second.sh $one
echo parm5 $5
# output is blank
#!/usr/bin/ksh
# second.sh : this script is called by first.sh
echo second shell $1
How can we avoid this problem ? (Saving the arguments in additional variables $p1, $p2, ... would work, but I don't like this solution)
Best regards,
Luc