On Sunday, October 14, 2012 10:20:10 PM Roland Mainz wrote:
> ... after some testing I reduced this to:
> -- snip --
> SHELL=~/bin/ksh
> 
> {
> cat <<EOF
>         print OK
>       exit 0
> EOF
> } | out=$( ${SHELL} 2>&1 )
> out2="${out}$?"
> 
> if [[ "$out2" == 'OK0' ]] ; then
>       print 'SUCCESS.'
> else
>       printf 'Expected "OK0", got %q\n' "$out2"
> -- snip --
> ... the test should print "SUCCESS." but currently prints "OK127" on
> both Solaris 11/B134/SPARC/64bit and SuSE 12.2/Linux/AMD64/64bit...
> which means the command substitution returns an exit code of 127.

It's related to the pipe. Running the command substitution in the shell 
process causes failure to resolve commands. (Replace your "$SHELL" with a 
function wrapper, builtin, or any absolute path. Same results.)

$ ( print 'print ok; exit 0' | x=$(ksh 2>&1); print -r "${x}, $?" )
ok, 0
$ ( set +m; print 'print ok; exit 0' | x=$(ksh 2>&1); print -r "${x}, $?" )
ok, 127
-- 
Dan Douglas

Attachment: signature.asc
Description: This is a digitally signed message part.

_______________________________________________
ast-developers mailing list
ast-developers@research.att.com
https://mailman.research.att.com/mailman/listinfo/ast-developers

Reply via email to