Checking arguments

Funny as I have another script with something like this and works. Don't have quotes.

  foreach f ($fnames)

      set fdrwtag = `echo $f | awk '/drw/'`
      set fsmptag = `echo $f | awk '/smp/'`
      set rgdttag = `echo $f | awk '/rgdt/'`

      if ($fdrwtag != "") set fdrw = 1  # Darwin tag detected.
      if ($fsmptag != "") set fsmp = 1  # Simplex tag detected.
      if ($rgdttag != "") set rgdt = 1  # Travel time error tag detected.

...

---------- Post updated at 08:36 PM ---------- Previous update was at 08:35 PM ----------

Yes I might have filenames with - such as n06-z30.ry

---------- Post updated at 08:39 PM ---------- Previous update was at 08:36 PM ----------

As you say it works if I include quotes ("$error" != "")

It's because the string starts with a hyphen and if thinks your testing the atributes of a file eg:

if ( -r file)
if ( -rwt file)
if ( -x file)

I checked, you're right.

---------- Post updated at 08:48 PM ---------- Previous update was at 08:46 PM ----------

I checked, you're right. Seemed I fixed the problem with wrong tags now.

PS: While metaword "continue" in "a switch within a while" gets you out more cleanly, as unlike "break", it is not a switch metaword.

Usually, one moves all arguments except any final list into exported variables named like the corresponding argument, and then checks for less than minimum or illegal combinations of arguments. This is order-independent, easier to read/maintain and ensures validity before main processing.

Yes I have thought of doing this and have started doing the changes. Thanks for suggesting using "continue" rather than "break".