I am debugging a ksh problem reported on Linux by one of our customers, and in the process of trying to reduce the testcase to something more manageable I came across some odd behavior. Different ksh versions behave differently for this tiny testcase (see below).
The ksh93 version shipped with Oracle and Red Hat Enterprise Linux 5 (Version AJM 93t+ 2010-02-02) prints too many lines of output, and reports the error "redirection failed" when the script tries to print more (when the test script parameter > 6). The dtksh version (Version M-12/28/93d) on Solaris 5.10 omits some output. The version on an OpenSolaris machine (Version M 93t 2008-11-04) dumps core without any output. I found some old Linux ksh binaries here: http://unixlabplus.com/linux-rpm/ . These appear to have a problem finding one of the scripts in $PATH, and don't produce any output, just errors. A version built from ftp://fr2.rpmfind.net/linux/ASPLinux/sources/SRPMS.12/ksh-20070111-1.src.rpm appears to work correctly for this testcase. It fails on the larger customer testcase. :::::::::::::: t1 :::::::::::::: export COUNT=${1:-1} export FPATH=. typeset -fu t2 cat <<EOF $(t2 t3 echo "$COUNT" abcdefghijklmnopqrstuvwxyz ) $(t2 t3 echo "$COUNT" ABCDEFGHIJKLMNOPQRSTUVWXYZ "$(t2 t3 call 1234567890123456 7890)") EOF :::::::::::::: t2 :::::::::::::: function t2 { script=${1}.sh shift ${script} $@ } :::::::::::::: t3.sh :::::::::::::: case $1 in "echo") i=$2 shift 2 while [ ${i} -gt 0 ] do echo "$@ $i" let i=i-1 done ;; "call") shift echo $(t2 t3 echo $COUNT ${.sh.version} $@) ;; esac :::::::::::::: Correct output (I believe): # /tmp/ksh.2007-01-11 t1 1 abcdefghijklmnopqrstuvwxyz 1 ABCDEFGHIJKLMNOPQRSTUVWXYZ Version M 1993-12-28 s 12345678901234567890 1 1 The EL5 /bin/ksh93 output: # /bin/ksh93 t1 1 abcdefghijklmnopqrstuvwxyz 1 abcdefghijklmnopqrstuvwxyz 1 ABCDEFGHIJKLMNOPQRSTUVWXYZ Version AJM 93t+ 2010-02-02 12345678901234567890 1 Version AJM 93t+ 2010-02-02 12345678901234567890 1 Version AJM 93t+ 2010-02-02 12345678901234567890 1 Version AJM 93t+ 2010-02-02 12345678901234567890 1 1 ABCDEFGHIJKLMNOPQRSTUVWXYZ Version AJM 93t+ 2010-02-02 12345678901234567890 1 Version AJM 93t+ 2010-02-02 12345678901234567890 1 Version AJM 93t+ 2010-02-02 12345678901234567890 1 Version AJM 93t+ 2010-02-02 12345678901234567890 1 1 # /bin/ksh93 t1 10 | wc t1[5]: t2: redirection failed 0 0 0 If I change the path to the script in t2 to ./${script}, the Linux ksh's produce correct output. That change also makes the EL5 ksh print the correct output. Also, when I move the t3.sh script to a different directory in $PATH, but not in $FPATH, the script produces correct output on EL5: # mv t3.sh /tmp # PATH=$PATH:/tmp # /bin/ksh93 t1 1 abcdefghijklmnopqrstuvwxyz 1 ABCDEFGHIJKLMNOPQRSTUVWXYZ Version AJM 93t+ 2010-02-02 12345678901234567890 1 1 # /bin/ksh93 t1 10|wc 20 640 5692 Solaris output: $ PATH=/usr/bin:/tmp $ mv t3.sh /tmp $ /usr/dt/bin/dtksh t1 1 abcdefghijklmnopqrstuvwxyz 1 ABCDEFGHIJKLMNOPQRSTUVWXYZ Version M-12/28/93d 12345678901234567890 1 1 $ mv /tmp/t3.sh . $ /usr/dt/bin/dtksh t1 1 t1[5]: t2: line 4: t3.sh: not found t1[5]: t2: line 4: t3.sh: not found t1[5]: t2: line 4: t3.sh: not found $ PATH=$PATH: $ /usr/dt/bin/dtksh t1 1 abcdefghijklmnopqrstuvwxyz 1 ABCDEFGHIJKLMNOPQRSTUVWXYZ 1 Looks like some bug in FPATH handling is causing io buffer corruption, or a file descriptor mixup? Thanks, Herbert. _______________________________________________ ast-developers mailing list [email protected] https://mailman.research.att.com/mailman/listinfo/ast-developers
