Trouble with PIPESTATUS

From: (lynto2...)

Greetings,

I'm having trouble getting the PIPESTATUS with the following code:

set -o pipefail
declare -a DIRLIST
DIRLST=$(ls -lda /tmp/foo/* | grep ^d | awk '{print $9}')
echo "0: ${PIPESTATUS[0]} 1: ${PIPESTATUS[1]} 2: ${PIPESTATUS[2]}"
#
if [ ${PIPESTATUS[0]} -eq 0 ] && [ ${PIPESTATUS[1]} -eq 0 ] && [ ${PIPESTATUS[2]} -eq "0" ]; then
echo "Direcotry List Good."
else
echo "Directory List Bad"
fi

Only PIPESATUS[0] is getting set. Any ideas what I'm doing wrong here?

Thanks in advance for any help.

Tom

Share |