C-Shell weirdness (count of words in a variable)

Greg Noel greg at ncr-sd.UUCP
Thu Mar 27 19:48:28 AEST 1986


In article <2024 at hao.UUCP> woods at hao.UUCP (Greg Woods) writes:
>> > set hosed
>> > echo $#hosed
>> > THEN you will get 0.
>> Sorry, I tried the example that is supposed to yield zero and I got one
>> instead.
>> The answer is that you can't have a variable with 0 words at all.
>> This fact I find counter-intuitive and undocumented
>    I stand corrected. It seems that $#var is either an error or a positive
>integer. Counterintuitive is debatable, however; .....

No, there is a way to get a C shell variable with zero words:
  set hosed = ()
Counterintuitive is relative -- this was obvous to me; but then, I wasn't
trying to do it, it was an accidential side-effect of doing:
  set something = (`some command`)
  if $#something ......
-- 
-- Greg Noel, NCR Rancho Bernardo    Greg at ncr-sd.UUCP or Greg at nosc.ARPA



More information about the Comp.bugs.4bsd.ucb-fixes mailing list