Git Product home page Git Product logo

bash_ini_parser's People

Contributors

davemds avatar machixian avatar rudimeier avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

bash_ini_parser's Issues

Executon fails with set -o errexit

In a script with "set -o errexit" the read_ini will fail. As a work-around, turn off errexit before using read_ini:

set +o errexit
read_ini ~/.script.ini
set -o errexit 

Running script fails when using "set -e" because post increment

If script is run using "set -e" it crashes on lines 177 ((LINE_NUM++)) and 193 ((SECTIONS_NUM++))
This is because post increment returns value (defaulted at 0) before addition and set -e reads this as false, returning error.

Related stackoverflow: here

Fix is easy enough as lines can be changed to use pre-increment ((++LINE_NUM)) and ((++SECTIONS_NUM))

License?

I want use bash_ini_parser on Embedded Distribution, so What's License of these?

Problem with the characters ' in value of variables

The substitution for the escape of ' not work.

I propose this correction :

diff --git a/read_ini.sh b/read_ini.sh
index 06b1bc8..2ae2a85 100755
--- a/read_ini.sh
+++ b/read_ini.sh
@@ -270,7 +270,7 @@ function read_ini()
                # enclose the value in single quotes and escape any
                # single quotes and backslashes that may be in the value
                VAL="${VAL//\\/\\\\}"
-               VAL="\$'${VAL/\'/\\\'}'"
+               VAL="\$'${VAL//\'/\'}'"
 
                eval "$VARNAME=$VAL"
        done  <"${INI_FILE}"

Parsing fails if Windows style CRLF line endings are used

First off: this is excellent and has saved me a lot of time. Thank you for making it and making it public.

I came across this issue when making the linux equivalent of an existing windows installer.

Works fine after converting the CRLF to LF. This is on Ubuntu 16.04.

My guess is that read only looks for LF and the trailing CR is causing it to fail the section regex test.

Example INI:

[smtp]
host=example.com
port=25
authentication=true
use_tls=true
from_email[email protected]
username=ex
password=expass

Save it with CRLF line endings and read_ini setup.ini -p setup -b 0 will fail with

Error: Invalid line:
1: [smtp]

End of line problem

When I put one variable into a ini file at the end of file, it doesn't read correctly.

OS - Solaris 11.3

Test#5 fails on var3 and 4 with the same issue
expected was ... \ ......
generated only had one \ versus the two in the correct file.

bash -version
4.1.17(1) - release
Current patch level for Solaris 11.3 - patched up as of this date. 2 May 2016.

Sorry, no cut and past using my current VM setup running Solaris (Intel) under VBOX.
if additional info is needed I should be able to reconfigure the VM to allow data / network outside of the box.

Feature request: add INI__ALL_SECTIONS to hold all section name

Add INI__ALL_SECTIONS can be used in such satution:
Say I want to backup a list of mysql databases, and each of them have a different username and password, and the list of databases can be grow in the future, so I configure all databases in a ini file like this:

[db01]
name=db-host01
username=user1
password=pwd01

[db02]
name=db-host2
username=user2
password=pwd2

And in the backup script I can use some thing like

for db in `echo INI__ALL_SECTIONS`; do 
  name="INI__${db}__name"
  echo "username of $db is ${!name}"
done

So everytime I need add a new database for backup, I only need to add a section in the ini file without change the backup sctipt.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.