Behavior of environmental variables depending on name

A forum for general AmigaOS 4.x support questions that are not platform-specific

Behavior of environmental variables depending on name

Postby JosDuchIt » Mon Oct 17, 2016 9:16 pm

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:>
JosDuchIt
 
Posts: 286
Joined: Sun Jun 26, 2011 6:47 pm

Re: Behavior of environmental variables depending on name

Postby salass00 » Tue Oct 18, 2016 12:08 am

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:>
User avatar
salass00
AmigaOS Core Developer
AmigaOS Core Developer
 
Posts: 502
Joined: Sat Jun 18, 2011 4:12 pm
Location: Finland

Re: Behavior of environmental variables depending on name

Postby JosDuchIt » Tue Oct 18, 2016 6:11 pm

Thanks a lot.

Is this documented somewhere?
JosDuchIt
 
Posts: 286
Joined: Sun Jun 26, 2011 6:47 pm

Re: Behavior of environmental variables depending on name

Postby chris » Wed Oct 19, 2016 9:48 pm

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

"." is a special character in AmigaDOS scripts.
chris
 
Posts: 551
Joined: Sat Jun 18, 2011 12:05 pm

Re: Behavior of environmental variables depending on name

Postby Daedalus » Thu Oct 20, 2016 12:15 pm

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.
User avatar
Daedalus
 
Posts: 42
Joined: Sat Jun 18, 2011 1:30 am
Location: From Ireland, living in Glasgow


Return to General AmigaOS

Who is online

Users browsing this forum: No registered users and 3 guests