You do not need the "2>/dev/null" part in a boolean (if) construct. It doesn't evaluate.
And. I do not know why your first line works. It should not.
---------- Post updated at 09:01 ---------- Previous update was at 08:45 ----------
FWIW:
#!/bin/ksh
isdigit()
{
case "$1" in
?(1|2|3|4|5|6|7|8|9|0)) ok=1;;
*) ok=0;;
esac
echo $ok
}
for i in 1 2 3 4 a d
do
echo "isdigit $i returns $(isdigit $i)"
done
is a traditional way to test a given character for character type, in this case a digit.
Traditional meaning "use the case statement"
This is getting more and more awkward. -o option works from a syntax point of view, but the expression doesn't return true when it encounters a star.
Furthermore:
if [$_CHAR == "*" ]; then
_VALUE=$_VALUE$_CHAR
else
_ISDIGIT="false"
fi
./test.sh: line 23: [3: command not found
./test.sh: line 23: [3: command not found
./test.sh: line 23: [3: command not found
./test.sh: line 23: [*: command not found