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

no output #10

Closed
naturalblaze opened this issue Aug 19, 2021 · 4 comments
Closed

no output #10

naturalblaze opened this issue Aug 19, 2021 · 4 comments

Comments

@naturalblaze
Copy link

I apologize if this is the wrong place for this. I cloned the repo and was just trying to use the sample sample.yml but I'm not getting any output when I run parse_yaml.sh. I am running CentOS Linux release 8.4.2105. Are there any package dependencies or anything special I need to do? Thanks!

@lumenpink
Copy link

Hi! I think this is the right place to ask for help.

For easier debug your problem, can you provide us some more info?

  1. Which shell are you using? you can get this with the command echo $SHELL
  2. Your shell probably be /bin/bash. So which version are you using? bash --version or echo $BASH_VERSION
  3. What command sequence are you trying exactly.

@naturalblaze
Copy link
Author

naturalblaze commented Aug 21, 2021 via email

@lumenpink
Copy link

Thanks for your reply!

The problem is:

  1. ./parse_yaml.sh sample.yml

parse_yaml.sh wasn't made to be called direct from command line (I'm working in adding this function, and soon I'll make a PR and hope that @mrbaseman approves. But now it really doesn't work this way.).

  1. source parse_yaml.sh eval $(./parse_yaml.sh sample.yml)

This is almost the right way to use it now. The first command source loads the parse_yaml (note the absence of .sh ending) function in your shell. After that, you can access the command parse_yaml in as a built-in command like ls or cd. You can read more about the source command here: https://linuxize.com/post/bash-source-command/
In the second line you are making an eval (evaluation) of the command execution. Which means, you will execute the output of the parse_yaml as a new script. This way you can read all the variables of the YAML file and load them in memory. This eval command doesn't have an output.
Anyway, the second command should be eval $(parse_yaml sample.yml) (without the ./ and the ending .sh because you aren't calling the script anymore but the loaded function - yes, I know the names are confusing).
And if you really need an output to see if things are running before load the variables, or can just call parse_yaml sample.yml (without the eval).
Don't forget that you have to run the source command every time you start the shell (open a new one or login again)

Sorry if the answer is confusing. You can ask again if you still have questions.

@mrbaseman
Copy link
Owner

right, it's explained in the README.md

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

No branches or pull requests

3 participants