trailing whitespace (Solved)
Posted: Wed 27 Dec 2017, 22:19
There is a strange behaviour I noticed with trailing whitespace.
The following isn't successful...
If I assume that there is no trailing whitespace....
An extra layer of brackets also solves the problem....
______________________________________________________
I checked with a gtkdialog script and there doesn't appear to be any
problem with trailing whitespace.
____________________________________
The following isn't successful...
Code: Select all
# A="Note: ";[ $A = "Note: " ] && echo successful
If I assume that there is no trailing whitespace....
Code: Select all
# A="Note: ";[ $A = "Note:" ] && echo successful
successful
Code: Select all
# A="Note: ";[[ $A = "Note: " ]] && echo successful
successful
I checked with a gtkdialog script and there doesn't appear to be any
problem with trailing whitespace.
Code: Select all
#!/bin/bash
# whitespace experiment
export DIALOG='<window>
<vbox>
<frame>
<hbox>
<entry>
<default>"Note: "</default>
<variable>MESSAGE</variable>
</entry>
</hbox>
</frame>
<button ok>
</button>
</vbox>
</window>
'
I=$IFS; IFS=""
for STATEMENTS in $(gtkdialog --geometry=+200+100 --program DIALOG); do
eval $STATEMENTS
done
# check for trailing whitespace
A="$MESSAGE";[ $A = "Note: " ] && xmessage success