Subject: bin/7351: ksh problem if last command of pipe is a shell built-in
To: None <gnats-bugs@gnats.netbsd.org>
From: C Kane <ckane@best.com>
List: netbsd-bugs
Date: 04/09/1999 19:28:36
>Number: 7351
>Category: bin
>Synopsis: ksh problem if last command of pipe is a shell built-in
>Confidential: no
>Severity: serious
>Priority: high
>Responsible: bin-bug-people (Utility Bug People)
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Fri Apr 9 19:35:01 1999
>Last-Modified:
>Originator: C Kane
>Organization:
>Release: NetBSD/i386 1.4_ALPHA 990408
>Environment:
System: NetBSD ckane5 1.4_ALPHA NetBSD 1.4_ALPHA (ckane4) #17: Thu Apr 1 23:10:16 PST 1999 root@ckane5:/usr/netbsd-current/src/sys/arch/i386/compile/ckane4 i386
>Description:
ksh appears to run the last component of a pipeline in a
child process which causes problems if setting envariables.
>How-To-Repeat:
This example:
echo test | read a
echo $a
should print "test" but prints a blank line.
This example:
#!/bin/ksh
ps -ax | while read PID TT STAT TIME COMMAND ARGS
do
case $COMMAND in
syslogd ) SYSLOGD=$PID ;;
portmap ) PORTMAP=$PID ;;
update ) UPDATE=$PID ;;
esac
echo syslogd=$SYSLOGD portmap=$PORTMAP update=$UPDATE
done
echo FINAL syslogd=$SYSLOGD portmap=$PORTMAP update=$UPDATE
demonstrates that the loop is run in a subshell and when it
exits, the envariables that were set are no longer set.
>Fix:
Unknown
>Audit-Trail:
>Unformatted: