Page 1 of 1

Behavior of environmental variables depending on name

Posted: Mon Oct 17, 2016 8:16 pm
by JosDuchIt
environmental variables are said to be used in scripts when preceded with a $ sign
If the name of the variable contains a "." dot the results are not as expected.
Is there a reason or could this be corrected?

Code: Select all

6.Env:> setenv y "value"
6.Env:> getenv y
value
6.Env:> echo $y
value
6.Env:> type y
value6.Env:>
6.Env> setenv .y "value"
6.Env:> getenv .y
value
6.Env:> echo $.y
$.y  ///???
6.Env:> type .y
value6.Env:> 
6.Env:> setenv y.1 "value"
6.Env:> getenv y.1
value
6.Env:> echo $y.1
value.1 /// ?????
6.Env:> type y.1
value6.Env:> 
6.Env:> setenv .y.1 "value"
6.Env:> getenv .y.1
value
6.Env:> echo $.y.1
$.y.1 ///???
6.Env:> type .y.1
value6.Env:>

Re: Behavior of environmental variables depending on name

Posted: Mon Oct 17, 2016 11:08 pm
by salass00
For weird variable names like that or other situations were AmigaDOS has trouble identifying where the variable name starts and ends you should use curly braces:

Code: Select all

8.RAM Disk:> setenv .y. "Hello World"
8.RAM Disk:> echo ${.y.}
Hello World
8.RAM Disk:>

Re: Behavior of environmental variables depending on name

Posted: Tue Oct 18, 2016 5:11 pm
by JosDuchIt
Thanks a lot.

Is this documented somewhere?

Re: Behavior of environmental variables depending on name

Posted: Wed Oct 19, 2016 8:48 pm
by chris
You can also start your script with something like:
.dot !

"." is a special character in AmigaDOS scripts.

Re: Behavior of environmental variables depending on name

Posted: Thu Oct 20, 2016 11:15 am
by Daedalus
JosDuchIt wrote:Is this documented somewhere?
I don't think it's specifically documented, but in general it's always been the case that special characters have to be treated carefully in AmigaDOS, especially in scripts. The documentation here talks about substitution of special characters in scripts, specifically brackets and dots.