Variable replacement with empty value #864
Replies: 1 comment
-
Unfortunately, this is not how environment variables work in general. By the time the environment variable data makes it into Pkl's process it has already been "expanded" and Pkl has no way of detecting that ❯ export foo="$bar-bar" # $bar is undefined
❯ bash # start a new shell, inheriting the environment
$ env | grep foo
foo=-bar Some shells like If you're expecting the value to match a specific pattern, you may be able to at least do some validation in Pkl using type constraints, eg. local foo: String(matches(Regex("<some regex>"))) = read("env:FOO") |
Beta Was this translation helpful? Give feedback.
-
Hello,
I use this code :
read("env:FOO")
If the env variable contains
$bar-bar
the$bar
is replaced by empty value.To help the developer to track bad defintioon, we could add a warning when a variable is defined without a value.
Beta Was this translation helpful? Give feedback.
All reactions