[CentOS] C5 BASH IF

Sat Feb 14 05:47:49 UTC 2015
Always Learning <centos at u64.u22.net>

On Sat, 2015-02-14 at 05:26 +0000, Always Learning wrote:

> NON-WORKING second comparison
> 
> 15 if [ $file='law00.css' ]
> 16   then
> 17        file=$dir/$file
> 18        echo "css"
> 19 else   
> 20        file=$dir/$file\.php
> 21        echo "no css"
> 22 fi
> 23 #----------------------------
> 
> Every comparison in the second test, including wrong comparisons,
> satisfy the test and caused the 'css' display.
> 
> When line 15 was changed to
> 
> 	15 if [ $file='law00css' ]
> 
> everything continued to match including items with no 'css' in the file
> name.

I re-ran the script with 'set -x' for

16 if  [ $file='law00css' ]
17   then
18        echo $file
19        echo "css"
20 else
21        echo "no css"
22 fi     

and received:-

+ '[' law45p07a01=law00css ']'
+ echo law45p07a01
law45p07a01
+ echo css
css



-- 
Regards,

Paul.
England, EU.      Je suis Charlie.