Bash and declare

John Macdonald john-Z7w/En0MP3xWk0Htik3J/w at public.gmane.org
Wed Mar 29 16:35:16 UTC 2006


On Wed, Mar 29, 2006 at 11:03:40AM -0400, kburtch-Zd07PnzKK1IAvxtiuMwx3w at public.gmane.org wrote:
> 
> 
> In addition to assigning attributes, declare is used with the nounset option.
>  By declaring variables, Bash is able to check for spelling mistakes in
> variables.  Otherwise Bash assumes that a badly spelled variable name is
> really a new variable, something Perl doesn't do.

If I understand you correctly, bash and perl are on an equal
footing here.

By default they allow use of all names to be accepted
as legitimate variable names, but with one optin setting
will only accept names that have been explicitly declared.
For short throwaway scripts, you may want the ease of the
unrestricted form, but as soon as you get into more serious
programming (larger or long-lived scripts) you switch to the
more disciplined form.  For perl, "use strict" will provide
the more disciplined environment.

Is there something more to  bash's nounset option than what
you describe above that would make it actually be "something
perl doesnt do"?

-- 
--
The Toronto Linux Users Group.      Meetings: http://tlug.ss.org
TLUG requests: Linux topics, No HTML, wrap text below 80 columns
How to UNSUBSCRIBE: http://tlug.ss.org/subscribe.shtml





More information about the Legacy mailing list