Displaying 4 results from an estimated 4 matches for "law00css".
2015 Feb 14
4
C5 BASH IF
...ot;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.
Baffled.
Are C5 BASH scripts restricted to only 1 IF comparison ?
--
Regards,
Paul.
England, EU. Je suis Charlie.
2015 Feb 14
4
C5 BASH IF
...f tests. And third, you generally should use
> double quotes around variables in tests so they continue to exist as
> an empty string if the variable happens to not be set.
Thanks for that. I assumed if test 1 worked, so would test 2.
Have re-run test 2 with
> 16 if [ $file = "law00css" ]
> 17 then
> 18 echo $file
> 19 echo "css"
> 20 else
> 21 echo "no css"
> 22 fi
and got
> + '[' law45p07a01 = law00css ']'
> + echo 'no css'
> no css
> + exit
which is correct (for the first t...
2015 Feb 14
0
C5 BASH IF
....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...
2015 Feb 14
0
C5 BASH IF
...ould use
>> double quotes around variables in tests so they continue to exist as
>> an empty string if the variable happens to not be set.
>
> Thanks for that. I assumed if test 1 worked, so would test 2.
>
> Have re-run test 2 with
>
>
>> 16 if [ $file = "law00css" ]
You still missed the part about quoting variables. You quote plain
strings to hold embedded spaces together (or single-quotes to avoid
parsing metacharacters). You use double quotes around $variables so
they don't disappear completely if the variable isn't set, causing a
syntax...