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

Adding very simple usage examples may be practical #2

Open
nicolashainaux opened this issue Oct 18, 2022 · 2 comments
Open

Adding very simple usage examples may be practical #2

nicolashainaux opened this issue Oct 18, 2022 · 2 comments

Comments

@nicolashainaux
Copy link

nicolashainaux commented Oct 18, 2022

Hello,

Nice and helpful project!

I wanted to test this on my firefox profile, but had to struggle just a little bit until I found out how to use it:

nico@xantico:~$ source .local/bin/bash-ini-parser.sh 
nico@xantico:~$ cd .mozilla/firefox
nico@xantico:~/.mozilla/firefox$ ini_file_read profiles.ini 

nico@xantico:~/.mozilla/firefox$ cat profiles.ini 
[Install46F492E0ACFF84D4]
Default=s25g8abr.dev-edition-default
Locked=1

[Install4F96D1932A9F858E]
Default=waxl9k8u.default
Locked=1

[Profile1]
Name=default-release
IsRelative=1
Path=v6gmyi1u.default-release

[Profile0]
Name=default
IsRelative=1
Path=waxl9k8u.default
Default=1

[General]
StartWithLastProfile=1
Version=2

nico@xantico:~/.mozilla/firefox$ ini_section_list profiles.ini 

nico@xantico:~/.mozilla/firefox$ ini_file_read 

nico@xantico:~/.mozilla/firefox$ ini_file_read --help

nico@xantico:~/.mozilla/firefox$ ini_file_read `cat profiles.ini`

nico@xantico:~/.mozilla/firefox$ cat profiles.ini | ini_file_read 

nico@xantico:~/.mozilla/firefox$ ini_file_read "k1=val1"
[Default]k1=val1

nico@xantico:~/.mozilla/firefox$ ini_file_read "`cat profiles.ini`"
[Install46F492E0ACFF84D4]Default=s25g8abr.dev-edition-default
[Install46F492E0ACFF84D4]Locked=1
[Install4F96D1932A9F858E]Default=waxl9k8u.default
[Install4F96D1932A9F858E]Locked=1
[Profile1]Name=default-release
[Profile1]IsRelative=1
[Profile1]Path=v6gmyi1u.default-release
[Profile0]Name=default
[Profile0]IsRelative=1
[Profile0]Path=waxl9k8u.default
[Profile0]Default=1
[General]StartWithLastProfile=1
[General]Version=2
nico@xantico:~/.mozilla/firefox$

(Finally found out reading the tests). Maybe something like a simple

ini_file_read "`cat myfile.ini`"

(or whatever is better) somewhere in the README or from a --help option, might be nice.

Thank you anyway, this was much shorter than re-creating it entirely myself :-)

@egberts
Copy link
Owner

egberts commented Dec 11, 2022

wow. an excellent example of passing a command in its argument to obtain its result.

also one of the downside of Bash scripting in trying to keep that from happening due to potentially for its malicious nature.

but nonetheless, a great find.

@egberts
Copy link
Owner

egberts commented Dec 11, 2022

would yet another function name ini_read_file work to your needs?

i thought I had one there but I think you are asking for what

  1. a standalone CLI

or/and

  1. shorter but more functional script (that does all the callings of ini_* functions.

if you write a simple example of what you expect and the expected output, I think I can whip that up

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

2 participants