Skip to content
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

Open
fiftydinar opened this issue Nov 30, 2024 · 3 comments
Labels
enhancement New feature or request

Comments

@fiftydinar
Copy link

fiftydinar commented Nov 30, 2024

Is your feature request related to a problem? Please describe.
Instead of need to do this:

import { get_env_var } from "std/env"

let home = get_env_var("HOME")
echo home

I simply want to do this:

echo ${HOME}

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
/

@fiftydinar fiftydinar added the enhancement New feature or request label Nov 30, 2024
@github-project-automation github-project-automation bot moved this to 🆕 New in Amber Project Nov 30, 2024
@b1ek
Copy link
Member

b1ek commented Dec 1, 2024

why not do this?

echo get_env_var("HOME")

also imo it is a better solution to allow for $ to be defined as a function, instead of creating a builtin:

import { get_env_var as $ } from "std/env"

echo $("HOME")

@b1ek
Copy link
Member

b1ek commented Dec 1, 2024

or maybe create a $ function in stdlib to allow for general bash syntax:

import { $ } from "std/util"

let a = "SMOL"
echo $("${nameof a},,") # smol

@fiftydinar
Copy link
Author

why not do this?

echo get_env_var("HOME")

It's not suitable if I want to do this:

var="${HOME}/Downloads/"

which I often do in bash scripts.

also imo it is a better solution to allow for $ to be defined as a function, instead of creating a builtin:

import { get_env_var as $ } from "std/env"

echo $("HOME")

Doesn't work, errors out (Unclosed interpolation)

or maybe create a $ function in stdlib to allow for general bash syntax:

import { $ } from "std/util"

let a = "SMOL"
echo $("${nameof a},,") # smol

Doesn't work, errors out (Unclosed interpolation)

I guess I'll wait for 0.3.6 version & try again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants