strange bash #?

M.W. Chang mwchang
Mon May 17 12:00:20 PDT 2004


#!/bin/bash
tar
echo $?
if [ $? == 0 ]
then
    echo "zero"
else
    echo "not zero"
fi

It didn't work. $? was 2, but it still printed "zero". Why?
is $? a number or a string?

-- 
   .~.    http://toylet.homeip.net
  / v \   Linux 2.4.22-xfs
/( _ )\  11:50pm up 1 day 8:00
   ^ ^    load average: 1.19 1.25 1.38




More information about the Linux-users mailing list