Fix load_config to allow it to read from stdin#77
Open
Conversation
Adds the ability to read INI style conifigs from stdin and switches to a continious read operation rather than multiple reads
hrpatel
requested changes
Jun 5, 2020
| while read -r line; do | ||
| # If first argument is a filename read it and pass it to the function | ||
| if [ -f "${1:-}" ]; then | ||
| print_settings='false' |
Member
There was a problem hiding this comment.
Should we allow flexibility here to allow printing?
E.g.
Suggested change
| print_settings='false' | |
| print_settings="${print_settings:-false}" |
So we can do something like:
print_settings=true load_config config foo
Loaded config parameter foo with value of 'bar'
foo=bar
Contributor
Author
There was a problem hiding this comment.
We do .. and we don't.
Print Setting will actually cause issues because we're allowing piping but it does not matter because that particular case will recurse so it will pick up the setting on the second run :)
| color_echo red "No config filename provided or data on stdin, exiting" | ||
| return 1 | ||
| else | ||
| print_settings="${print_settings:-true}" |
Member
There was a problem hiding this comment.
I can't figure out when we ever reach this case...
Contributor
Author
There was a problem hiding this comment.
For some reason my reply is missing, think about the function being called iteratively ...
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds the ability to read INI style conifigs from stdin and switches to a
continious read operation rather than multiple reads