SUMMARY: korn shell vs bourne shell on Solaris 2.5.1

TOBY POTTS (tobypotts@pmsc.com)
Thu, 08 May 1997 09:07:19 -0400


Thanks to all who replied:

ranks@avnasis.jccbi.gov (James T Ranks)
John Justin Hough <john@oncology.uthscsa.edu>
John Ballard <johnb@ocean.washington.edu>
Glenn Satchell <Glenn.Satchell@uniq.com.au>
vvuppa@unix.cis.state.mi.us (Vasu Vuppala (DCCI))
Mike Nibeck <nibeck@Pentagon-EMH6.army.mil>


The ORIGINAL question is at the bottom of this message. The majority
of you answered with the following:

The pipe that was used runs as a subshell.

From the sh man pages:

Because commands in pipelines are run as separate processes, variables
set in a pipeline have no effect on the parent shell.

Again, thanks to all who responded.


ORIGINAL Q:

Hello all,

I have a shell script that I am trying to run which parses through our
Oracle Database file (oratab).

Korn Shell seems to value a variable within a WHILE statement, and
re-value it AFTER the WHILE to its original value. Is this normal for
the Korn shell????

Logic...


db_there="NO"
cat $ORATAB | while read LINE && [ "$db_there" = "NO" ] do
case $LINE in
\#*) ;; #comment-line in oratab *)
ORACLE_SID=`echo $LINE | awk -F: '{print $1}' -`

# Set up environment and export for called programs if [ "$ORACLE_SID"
= "${dbn}" ]
then db_there="YES"
echo "$ORACLE_SID in oratab : db_there is $db_there."
fi
ORACLE_HOME=`echo $LINE | awk -F: '{print $2}' -`
esac
done
echo "after done, db_there is $db_there"

if [ "$db_there" = "NO" ]
then echo "${dbn}:${ORACLE_HOME}:N" >> $ORATAB
fi

-------------

I set db_there to its initial value (NO) at the top. Then db_there is
set to YES if the value is found in the oratab file. BUT, after the
script executes the "done" for the "which" statement, it seems to
re-value db_there to NO again.

Does anyone have an explanation for this???? Any suggestions would be
VERY MUCH appreciated.

Toby Potts
Policy Management Systems Corporation