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

A Couple Suggestions #4

Open
xrxca opened this issue Mar 19, 2024 · 0 comments
Open

A Couple Suggestions #4

xrxca opened this issue Mar 19, 2024 · 0 comments
Labels
bug Something isn't working documentation Improvements or additions to documentation good first issue Good for newcomers

Comments

@xrxca
Copy link

xrxca commented Mar 19, 2024

I was looking for bash handling of INI files rather than rolling my own and came across this which has some usable ideas.

However I find the returns on some of your functions to be backwards, for example:
ini_section_test returns 0 if the section doesn't exist and 1 if it does, which seems to got totally against posix shell conventions which is zero for true and non-zero for false.

to use your function as part of regular shell operations, the test has to be negated

if ! ini_section_test "${ini_data}" SectionName
then
    echo "Section Exists"
else
    echo "Section not Found"
fi

Which is highly counter intuitive: if not section exists then section exists??

Secondly I'd suggest being able to load the inifile into a global variable and never have to use it again, rather than passing ${ini_data} for every read or test, perhaps adding simple wrappers for the get/list functions that use the preloaded data. Just an idea...

Also generally INI files sections and keys are case-insensitive, not a deal breaker but an item of note.

@egberts egberts added bug Something isn't working documentation Improvements or additions to documentation good first issue Good for newcomers labels May 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working documentation Improvements or additions to documentation good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

2 participants