Bash scripts troubles with Tomsrtbt... Help!

Stephane Boireau <[email protected]>
Newsgroups gmane.linux.tomsrtbt
Organization MENRT
Message-ID <[email protected]>
Hi,

I have troubles with Bash scripts an Tomsrtbt:
I don't succeed to use "counter".
And I don't succed with zero-length-string tests:

#!/bin/sh
I=0
echo "Initial value:$I"
echo "Numbers from 0 to 9:"
while [ $I -lt 10 ] ; do
echo $I
#I=$(($I+1))
I=$[$I+1]
#Both solutions are OK for Mdk8.2
done
echo "1st stage ended"
echo "-----------------"
#This first stage doesn't work:
#With I=$(($I+1))
#I get :
#0+1: not found
#[: 10:unknown operand

#With I=$[$I+1]
#I get :
#[:$[0+1]:bad number


#-----------------------------------------------
liste="1 2 3 4 5 6"
for I in $liste
do
echo $I
done
echo "2nd stage ended"
echo "-----------------"
#This second stage is OK.


#-----------------------------------------------
A=''
while true; do
echo "Hit 'Quit' to quit, or not-empty-string to follow up."
echo "Hit value for A:"
read A
if [ ! -z $A ]; then
	if [ $A = "Quit" ]; then
		exit
	else
		break
	fi
fi
done
echo "You hit: $A"
echo "3rd stage ended"
echo "-----------------"
#With 'Quit' and 'not-empty-strings' it works,
#but with empty-string, I get:
#[: -z: argument expected


#-----------------------------------------------
B=''
while true; do
echo "Hit value for B:"
read B
if [ ! -z $B ]; then
break
fi
done
echo "You hit: $B"
echo "4rth stage ended"
echo "-----------------"
#With 'not-empty-strings' it works,
#but with empty-string, I get:
#[: -z: argument expected


#-----------------------------------------------
C=''
while [ -z $C ]; do
echo "Hit value for C:"
read C
done
echo "You hit: $C"
echo "5th stage ended"
echo "-----------------"
#I can't do anything.
#An error occurs and I can't hit anything
#I get:
#[: -z: argument expected


#-----------------------------------------------
while [ ! $D ]; do
echo "Saisir une valeur pour D:"
read D
done
echo "Vous avez saisi: $D"
echo "C'est fini!"
#I can't do anything.
#An error occurs and I can't hit anything
#I get:
#[: argument expected


What should I do?
What is the syntax with Tomsrtbt?
In what way does the shell differ from the one I use with Mdk8.2
(my script is OK with Mdk8.2)

Thank you for all.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.