I just stumbled across a discrepancy when quoting empty variables.

  set -- ""; print $#                         # prints 1
  unset x; set -- "$x"; print $#              # prints 1

But:

  unset x; set -- "[EMAIL PROTECTED]"; print $#               # prints 0
  typeset x; set -- "[EMAIL PROTECTED]"; print $#             # prints 0

I find this a little confusing. I always thought that any expression in double quotes which evaluates to nothing counts as one word.

Interestingly, bash exhibits a similar, though slightly more inconsistent behavior:

   unset a; set -- "[EMAIL PROTECTED]"; echo $#               # prints 0
   typeset a; set -- "[EMAIL PROTECTED]"; echo $#             # prints 1

I asked for that on the bash list and got an answer from Chet Ramey:

... Bash
has traditionally treated `typeset a' as equivalent to `typeset a=""'
instead of creating a `placeholder' variable that exists in a sort of
limbo.  That's different from things like `export a' or `readonly a',
and probably inconsistent enough to be worth changing for bash-4.0.

How is the situation in ksh? Is this behavior intended or will it also change some day?

Regards,
Bernd

--
Bernd Eggink
[EMAIL PROTECTED]
http://sudrala.de
_______________________________________________
ast-developers mailing list
[email protected]
https://mailman.research.att.com/mailman/listinfo/ast-developers

Reply via email to