[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Small Query re Variables

On Thu, Mar 29, 2001 at 05:12:04PM +0100, Michael Boyd wrote:
> In reply to a recent posting of mine one or two people suggested
> removing the $ sign from the start of the variables in my firewall
If this is a shell script, then you _must_ use the "$" unless you are
setting the variable.  Otherwise the following 
characters won't be considered a variable name.  If you need to put the
characters next to other characters, you can use the following example

set filename=file
echo filename		# "filename"
	# Not interpreted as variable
echo $filename		# "file"
	# Interpreted as variable
echo $filename.gz	# "file.gz"
	# Interpreted as variable; stops at char that doesn't match (a-z, A-Z, 0-9, -, _)
echo $filename2.gz	# ".gz"
	# Interpreted as variable; number interpreted as part of variable (this isn't what we want)
echo ${filename}2.gz	# "file2.gz"
	# Chars inside "${" and "}" interpreted as variable, all subsequent stuff isn't (this _is_ what we want)

> script.  In R. Ziegler's book he definitely uses $ at the start of
> variables.  Is it just a convention that $ are/are not used or is there
It isn't used when you set a variable (set filetype=mp3)
> some other reason?
> I know this isn't really a firewall question but I wanted to make sure
> my query reaches the people who kindly replied to my previous posting.  
> :-)
> Mike
/ Knowledge is like a river:  The deeper it is      \
\     the less noise it makes.                      /
/    http://xsdg.hypermart.net|xsdg@softhome.net    \

Reply to: