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

Questions about environment variables #347

Closed
dddachui opened this issue Feb 16, 2023 · 3 comments
Closed

Questions about environment variables #347

dddachui opened this issue Feb 16, 2023 · 3 comments
Labels
question Further information is requested

Comments

@dddachui
Copy link

I wonder if bashly supports global variables. Use the shell command to obtain some system parameters, such as the system version marked in/etc/centos-release, and use it as global variables after being intercepted by the command. The examples I see are set strings, and the default marked in the example is string type

@DannyBen
Copy link
Owner

DannyBen commented Feb 16, 2023

You have two options to implement what are describe:

Option 1: Implement it yourself, in the initialize function

# src/initialize.sh
TEST="${TEST:-$(git --version)}"

Option 2: Assign a default value using the bash $(...) syntax

# bashly.yml
environment_variables:
- name: git_version
  help: Set your Git version
  default: $(git --version)

@DannyBen DannyBen added the question Further information is requested label Feb 16, 2023
@DannyBen
Copy link
Owner

One more thing - if you need to extract information from the system, you don't need to employ environment variables at all.

Just add a library function (bashly add lib), and set it to extract any information you want.

Use environment variables only for things that you want the user to be able to override.

@dddachui
Copy link
Author

ok

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants