title: shell Can't exit while loop normally.
body: <pre><code>$ cat Judge_file.sh
  #!/bin/bash
  i=1
  while [ $i ];do
      read -p "Enter your MO or attribute name: " name
      if [ $name = "q" ];then
          i=0
          continue
      else
          grep -q $name *.txt    #check character existence in currently directory of all .txt file
          if [ $? -eq 0 ];then
              echo "Name exists,send to file 2"
              echo $name &gt;&gt; 2.txt
          else
              echo "Name missing,send to file 1"
              echo $name &gt;&gt; 1.txt
          fi
      fi
  done
  $ . ./Judge_file.sh
  Enter your MO or attribute name: chenghuang
  Name exists,send to file 2
  Enter your MO or attribute name: llkk
  Name missing,send to file 1
  Enter your MO or attribute name: q
  Enter your MO or attribute name: q
  Enter your MO or attribute name: q
  </code></pre>
  
  <p>This is a program used for judge a character existence.</p>
  
  <p>When I type "q", it should be exited. but why it still let me input.</p>
  
  <p>and one thing really strange when I verified the <code>while [ $i ]</code> as <code>while [ 0 ]</code> ,then while loop still let me input , until I type Ctrl+c exit.</p>