-
Notifications
You must be signed in to change notification settings - Fork 92
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Feature] Support referencing existing variable values directly without need for get_env_var
#623
Comments
why not do this?
also imo it is a better solution to allow for
|
or maybe create a $ function in stdlib to allow for general bash syntax:
|
It's not suitable if I want to do this:
which I often do in bash scripts.
Doesn't work, errors out (Unclosed interpolation)
Doesn't work, errors out (Unclosed interpolation) I guess I'll wait for 0.3.6 version & try again. |
@fiftydinar I like this idea to reference outer shell variables with
I think that this one is more flexible and let's you assign a default value (optionally) @b1ek @Mte90 @hdwalters @mks-h you guys on board with this idea too? If so then we can add this feature in the upcoming version 0.5.0 (we will no longer release patch versions including new features, the iteration cycle will remain somewhat similar) |
I like the idea of declaring environment variables, however there are some considerations: First of all, I don't see a need to use them differently from normal variables. And regarding syntax, we can't use the And then there's the issue with data types — env variables should obviously be considered P.S. In Bash there's also a technical difference between non-declared or |
@Ph0enixKM I'm not sure I like this
This idea has several advantages:
We would probably have to enforce a space after N.B. If we do implement this, I think we should explicitly disallow |
@mks-h You claim that environment variables should always be treated as
|
And perhaps the most canonical way to unset environment variables would be like this:
I don't have any strong opinions on how to deal with a reference to an unset variable, but perhaps defaulting to an empty string would be the simplest way, and also consistent with Bash behaviour. |
@mks-h I don't think it makes sense to restrict environment variable declarations to top of file. This seems overly prescriptive, and disallows use cases where we need to modify an environment variable between running subprocesses. |
I don't think we can express a variable to be both Text and [Text] in Amber. Even if we merge the union types (we haven't yet, have we?), we would still not be able to express it (because it's a "one of" kind of type). The most natural type of an environment variable would be Text, because it is basically the raw input. And an array is really just a Text split up by a delimiter. Of course, having each env variable to be a [Text] split by whitespace is still an option, but that will make it less convenient to use with strings.
The idea is that environment variables are basically an API similar to CLI inputs. Therefore they should, first of all, be explicitly defined. And second, the top of the file would be a very logical and easy to access location for those who are reading the script.
I'm not sure what you mean, but it shouldn't because you should be able to modify them (without exporting) just like regular Amber variables. |
We can argue about specifics, but it would be useful to agree on a general approach. What do you think @Ph0enixKM, @fiftydinar, @b1ek? |
@mks-h just like
I think that we can use it for renaming environment variables:
If we accept this syntax, then it'd be easier to state of which type is the variable. We could also perform some Zod-like runtime type checking.
Default type would be Also. What do you dislike about this syntax, @hdwalters? |
First some assumptions. When you write:
I think you mean "bring Bash environment variable I don't like this because (i) you have to remember two different names With my suggestion, environment variables are differentiated by having an initial This way, there's less syntax for the user to remember: ordinary usage works like Amber variables, and string interpolation works (almost) like Bash. The other advantage is that we can leverage the existing variable handling Rust code, which means it would be simpler to implement. |
@hdwalters how would you syntactically differentiate variable from command:
Currently
|
I previously asked whether Heraclitus was capable of distinguishing between Is it possible to make Heraclitus also return |
Oh, I may have misread that; were you suggesting that we should keep |
Is your feature request related to a problem? Please describe.
Instead of need to do this:
I simply want to do this:
It is not convenient to use
get_env_var
every time you need to reference some existing variables.Describe the solution you'd like
Maybe
$var
,${var}
or something similar can be used to reference those?Describe alternatives you've considered
Besides keeping this as is (as worse alternative), I see no alternative.
Additional context
/
The text was updated successfully, but these errors were encountered: