On Tue, Jun 04, 2013 at 04:39:31PM +0530, kartik...@gmail.com wrote:
> Description:
> A while inside a while loop (nested while) doesnt work and also the vim /gvim 
> doesnt highlight the second while loop

For issues with the vim/gvim highlighting, you'd need to report the
problem in vim, not in bash.

> example code is given
> 
> while [ "ka" = $name ] 
> do 
>   echo "nothing\n"
>   while [ "ka" = $name ] //this while is not highlighted
>   do
>     echo "everything\n"
>   done
> done

You have a quoting mistake here.  "$name" should be quoted, or this will
fail if the variable contains multiple words separate by spaces.

imadev:~$ name="first last"
imadev:~$ [ "ka" = $name ]
bash-4.3: [: too many arguments

This code should work:

while [ "ka" = "$name" ]
do
  printf "nothing\n\n"
  while [ "ka" = "$name" ]
  do
    printf "everything\n\n"
  done
done

(It goes into an infinite loop when name=ka, but presumably that's what
you wanted.)

Reply via email to