Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Bug with unset variables



On 11/11/20, Felipe Contreras <felipe.contreras@xxxxxxxxx> wrote:
> On Wed, Nov 11, 2020 at 12:17 PM Roman Perepelitsa
> <roman.perepelitsa@xxxxxxxxx> wrote:
>> > Not only does this behavior differ from all other shells, but
>> > basically all languages.
>>
>> All languages? That seems exaggerated. How about this?
>>
>>   int var;
>
> You are specifying a type. I obviously meant all languages where you
> can do the equivalent of "declare var" (without a type).
>
> That being said, the most similar to shell's "declare var" in C is
> "char *var" which defaults to null on most systems.

This is certainly not true, just for the record. Variables in global
or static scope are initialized to 0 regardless of type, whereas
others are uninitialized (meaning they contain garbage, not that they
magically know that they haven't been assigned to).

-- 
Mikael Magnusson




Messages sorted by: Reverse Date, Date, Thread, Author