Behavior of environmental variables depending on name

A forum for general AmigaOS 4.x support questions that are not platform-specific
Post Reply
JosDuchIt
Posts: 291
Joined: Sun Jun 26, 2011 5:47 pm
Contact:

Behavior of environmental variables depending on name

Post 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:>

User avatar
salass00
AmigaOS Core Developer
AmigaOS Core Developer
Posts: 521
Joined: Sat Jun 18, 2011 3:12 pm
Location: Finland
Contact:

Re: Behavior of environmental variables depending on name

Post 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:>

JosDuchIt
Posts: 291
Joined: Sun Jun 26, 2011 5:47 pm
Contact:

Re: Behavior of environmental variables depending on name

Post by JosDuchIt »

Thanks a lot.

Is this documented somewhere?

chris
Posts: 552
Joined: Sat Jun 18, 2011 11:05 am
Contact:

Re: Behavior of environmental variables depending on name

Post by chris »

You can also start your script with something like:
.dot !

"." is a special character in AmigaDOS scripts.

User avatar
Daedalus
Posts: 42
Joined: Sat Jun 18, 2011 12:30 am
Location: From Ireland, living in Glasgow
Contact:

Re: Behavior of environmental variables depending on name

Post 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.

Post Reply