http://bugs.grommit.com/show_bug.cgi?id=586

           Summary: Need "hotfix" for issue with pipes in command
                    substitution
           Product: ksh93-integration
           Version: unspecified
          Platform: All
        OS/Version: Solaris 11/Nevada
            Status: NEW
          Severity: blocker
          Priority: P3
         Component: App/ksh93
        AssignedTo: ksh93-integration-discuss at opensolaris.org
        ReportedBy: roland.mainz at nrubsig.org
                CC: roland.mainz at nrubsig.org, april.chin at sun.com


We need to backport a fix to our ast-ksh.2008-10-10 tree to handle a problem
with pipes in a command substitution which originally showed-up as build
failure in the OS/Net codebase when /sbin/sh+/usr/bin/sh are hardlinked to
ksh93 - the build stops with exit code 127 in the following Makefile statement:
-- snip --
*** Error code 127
The following command caused the error:
TARG=`echo sischeck.obj64 | /usr/bin/cut -d'.' -f2`; \
MODSYMS=tun.symbols.$TARG; \
if [ -f "tun.global-objs.$TARG" ]; then \
        /usr/bin/grep -v '#' tun.global-objs.$TARG |/usr/bin/grep . | \
            /usr/bin/sort -u > $MODSYMS.tmp; \
        /usr/ccs/bin/nm $TARG/tun |/usr/bin/grep OBJT |/usr/bin/grep -v
UNDEF | \
            /usr/bin/cut -d'|' -f8 |/usr/bin/grep -v '^___const_' | \
            /usr/bin/grep -v '\.[0-9]*$' |/usr/bin/sort -u \
            > $MODSYMS.tmp.new; \
        /usr/bin/diff $MODSYMS.tmp $MODSYMS.tmp.new > $MODSYMS.diff || \
            (echo "warning: tun symbol checking:" \
            "global variable(s) introduced and/or removed."; \
            /usr/bin/cat $MODSYMS.diff; exit 1) \
fi
make: Fatal error: Command failed for target `sischeck.obj64'
-- snip --

After some experimentation it boils down to this (sporadic) failure:
-- snip --
$ sh -c 'set -o errexit ; TARG=`echo sischeck.obj64 | /usr/bin/cut -d'.' -f2`'
; print $?                    
0
$ sh -c 'set -o errexit ; TARG=`echo sischeck.obj64 | /usr/bin/cut -d'.' -f2`'
; print $?                    
0
$ sh -c 'set -o errexit ; TARG=`echo sischeck.obj64 | /usr/bin/cut -d'.' -f2`'
; print $?                    
0
$ sh -c 'set -o errexit ; TARG=`echo sischeck.obj64 | /usr/bin/cut -d'.' -f2`'
; print $?                    
127
$ sh -c 'set -o errexit ; TARG=`echo sischeck.obj64 | /usr/bin/cut -d'.' -f2`'
; print $?
0
-- snip --
In most cases I get a "0" as return code but for one test run I get a "127".
And after some further experiementation I reduced this to this test case:
$ while true ; do \
  /usr/bin/amd64/ksh93 -c 'set -o errexit ; TARG=`echo sischeck.obj64 |
/usr/bin/cut -d'.' -f2`' || { print $? ; break ; } ;
  done #
On Solaris 11/x86 it runs for 15-20 seconds and then returns
with "127" but on Solaris 11/SPARC it runs for 10mins and then
fails with error code "127", too.

Another syptom is the failure of the following testcase from April:
-- snip --
myfunc ()
{ 
        pipedcmd=`printf "hi" | tr "h" "H"`
        echo $pipedcmd

        return 0
}

foo=`myfunc`
retval=$?

if [ "$foo"X != "HiX" ]; then
        echo "myfunc returned $foo; expected 'Hi'"
fi

if [ $retval -ne 0 ]; then
        echo "command substitution calling myfunc returned $retval; expected 0"
else
        echo "command substitution calling myfunc successfully returned 0"
fi
-- snip --
This script should print "command substitution calling myfunc successfully
returned 0" but prints "command substitution calling myfunc returned 127;
expected 0" instead.


-- 
Configure bugmail: http://bugs.grommit.com/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.

Reply via email to