Skip to content
This repository was archived by the owner on Nov 24, 2025. It is now read-only.
This repository was archived by the owner on Nov 24, 2025. It is now read-only.

[Question]: Parser multi ini file #77

@rayee-github

Description

@rayee-github

What is your question?

How to parser multi ini in a script, when [section] is repeated, the content will overlap, is there any way to clear the last ini?

For example:

a.ini

[section1]
value1=a
value2=b

[section2]
value1=c
value2=d

b.ini

[section1]
value1=1
value2=2

[section3]
value1=3
value2=4

test.sh

#!/usr/bin/env bash

# Load in the ini file parser
source ini-file-parser.sh

# Load a.ini
process_ini_file 'a.ini'

# Display a specific value from a specific section
echo $(get_value 'section1' 'value1')

# Load b.ini
process_ini_file 'b.ini'

# Display a specific value from a specific section
echo $(get_value 'section1' 'value1')

The output is not correct:

$ ./test.sh
a
[ WARNING ] key value1 - Defined multiple times within section section1
[ WARNING ] key value2 - Defined multiple times within section section1
a1

Code of Conduct

  • I agree to follow this project's Code of Conduct

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions