Re: selecting into unix variable
From: Ian Parkin <twod_at_tdl.com>
Date: 1995/11/01
Message-ID: <476orl$vh0_at_news.tdl.com>#1/1
fi
chmod +x 1 2 3
./1
echo ${?}
./2
echo ${?}
./3
echo ${?}
/bin/rm -f 1 2 3
exit 0
Date: 1995/11/01
Message-ID: <476orl$vh0_at_news.tdl.com>#1/1
[Stuff about a magic value of 256 deleted]
: There are Unix limits to the size of variables - and they differ : between flavours.
I hope you don't mean that there is a 256 character limit to Unix variables !
I think the 256 limit should, in fact, be 255 which indicates the maximum value that ${?} or ${status} can hold.
A quick example :
#!/bin/sh
if [ -f 1 -o -f 2 -o -f 3 ]
then
echo "Yoiks can't run a target file exists" exit 1
fi
echo 'exit 255' > 1 echo 'exit 256' > 2 echo 'exit 257' > 3
chmod +x 1 2 3
./1
echo ${?}
./2
echo ${?}
./3
echo ${?}
/bin/rm -f 1 2 3
exit 0
- snip --
The expected output of the above is :
255
0
1
IAP Received on Wed Nov 01 1995 - 00:00:00 CET