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

Fix load_config to allow it to read from stdin #77

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

antevens
Copy link
Contributor

Adds the ability to read INI style conifigs from stdin and switches to a
continious read operation rather than multiple reads

Adds the ability to read INI style conifigs from stdin and switches to a
continious read operation rather than multiple reads
@antevens antevens requested a review from hrpatel May 27, 2020 16:23
shtdlib.sh Show resolved Hide resolved
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'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 :)

shtdlib.sh Show resolved Hide resolved
color_echo red "No config filename provided or data on stdin, exiting"
return 1
else
print_settings="${print_settings:-true}"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can't figure out when we ever reach this case...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For some reason my reply is missing, think about the function being called iteratively ...

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

Successfully merging this pull request may close these issues.

2 participants