Re: Problem with if/else



On Mar 29, 7:43 pm, Glenn Jackman <gle...@xxxxxx> wrote:

if { "$stringA" == "$stringB" }

You don't need the quotes there. The act of substituting variables does
not introduce new word boundaries.

Beware that the two variants are not equivalent.
If you remove the quotes, the comparison may be done after conversion
to numerical values
For example,

% set stringA 16
% set stringB 0x10
% if {$stringA==$stringB} {puts yessss}
yessss

Moreover, not so long ago (threshold version please ?), the test could
even spark an exception on invalid conversions like "08" (invalid
octal number). Today (tested on my 8.4.14) invalid octals just refuse
to be converted and the comparison occurs in strings' realm. Much
sweeter !

-Alex

.



Relevant Pages

  • Re: re-quoting (aka reconstituting a command line)
    ... argument do not need the illegible '\'' conversion. ... contains any single quotes, ... I discovered that bash has its own re-quoting functionality in the ...
    (comp.unix.shell)
  • Ruby to convert US to UK punctuation/spelling?
    ... US English and punctuation to UK English and punctuation. ... conversion tool but doesn't seem to exist. ... I'm starting with utf8 rtf documents which have printer's quotes (i.e., ...
    (comp.lang.ruby)
  • Strange characters when converting from Word 2007 to Word 2003
    ... things seem to happen in conversion: ... right double quotes convert to an at symbol ... apostrophes convert to an equal sign ... for the uppercase A. ...
    (microsoft.public.word.newusers)
  • Re: Help with athe syntax for Net Use command
    ... Then you'll get a prompt for the password. ... invalid for ... ... > Here, below, is the syntax I'm planning to use - a few questions follow. ... >> double quotes because the UNC has a space in it. ...
    (microsoft.public.backoffice.smallbiz2000)
  • Re: Iran and the Bomb
    ... offset your quotes with> on the left as most newsreaders do? ... "No. I'm suggesting that the Islamist jihad is a world-wide ... Any religion that relies upon conversion or dictates that efforts be made to ...
    (rec.arts.mystery)