Bash and declare

Neil Watson tlug-neil-8agRmHhQ+n2CxnSzwYWP7Q at public.gmane.org
Wed Mar 29 16:14:02 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.

#!/bin/bash

declare nounset MYVAR=50

MIVAR=42

printf $MYVAR

How does declare prevent mispelled variables?

BTW, when using the Strict module in Perl the variable MIVAR above could
not happen.

-- 
Neil Watson             | Gentoo Linux
System Administrator    | Uptime 25 days
http://watson-wilson.ca | 2.6.11.4 AMD Athlon(tm) MP 2000+ x 2
--
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