title: bash script showing file permissions gives wrong output
body: <p>I am learning bash and wish you guys could help me out what's going on with the following script</p>
  
  <pre><code>#!/bin/bash
  
  #primer if
  if [ -f $file1 ]; then
          echo "file1 is a file"
  else
          echo "file1 is not a regular file"
  fi
  #segundo if
  if [ -r $file1 ]; then
          echo "file1 has read permission"
  else
      echo "file1 doesnot have read permission"
  fi
  #tercer if
  if [ -w $file1 ]; then
          echo "file1 has write permission"
  else
      echo "file1 doesnot have write permission"
  fi
  #cuarto if
  if [ -x $file1 ]; then
          echo "file1 has execute permission"
  else
      echo "file1 doesnot have execute permission"
  fi
  </code></pre>
  
  <p>It looks to me that it does not matter if I change the file permissions because output is always the same</p>
  
  <pre><code>fmp@eva00:~/Books/2012/ubuntu_unleashed$ ./script.sh 
  file1 is a file
  file1 has read permission
  file1 has write permission
  file1 has execute permission
  fmp@eva00:~/Books/2012/ubuntu_unleashed$ ll file1
  -rw-r--r-- 1 fmp fmp 0 Aug 30 13:21 file1
  fmp@eva00:~/Books/2012/ubuntu_unleashed$ chmod 200 file1
  fmp@eva00:~/Books/2012/ubuntu_unleashed$ ./script.sh 
  file1 is a file
  file1 has read permission
  file1 has write permission
  file1 has execute permission
  fmp@eva00:~/Books/2012/ubuntu_unleashed$ ll file1
  --w------- 1 fmp fmp 0 Aug 30 13:21 file1
  fmp@eva00:~/Books/2012/ubuntu_unleashed$ chmod 000 file1 
  fmp@eva00:~/Books/2012/ubuntu_unleashed$ ll file1
  ---------- 1 fmp fmp 0 Aug 30 13:21 file1
  fmp@eva00:~/Books/2012/ubuntu_unleashed$ ./script.sh 
  file1 is a file
  file1 has read permission
  file1 has write permission
  file1 has execute permission
  </code></pre>
  
  <p>file1 can be empty or not and still output is the same, doing the same test</p>
  
  <p>Can anybody explain to me what is wrong? </p>
  
  <p>Thanks</p>
  
  <p>BTW the script here is a modified version of compare3 on page 233 of ubuntu unleashed book 2011 edition (Book site <a href="http://ubuntuunleashed.com/" rel="nofollow">http://ubuntuunleashed.com/</a>)</p>