Skip to content

Conversation

milanbalazs
Copy link
Contributor

Why:

If there is empty trailing line in the INI file you can get the following error:

eval: line 64: syntax error near unexpected token `}'

Solution:

  • My change removes the empty lines from INI file.

My test INI file:

# This config file is used for testing

[SERVER]
user            = user
pws             = password

My test code:

#!/bin/bash -e

SCRIPT_FULL_PATH=$(readlink -f "${BASH_SOURCE[0]:-${0}}")
SCRIPT_DIR_PATH="${SCRIPT_FULL_PATH%/*}"

source "${SCRIPT_DIR_PATH}/bash_ini_parser.sh"

cfg_parser "${SCRIPT_DIR_PATH}/configs/servers.ini"

echo "DONE"

Test run without my change (With an extra echo):

 >>> ./test.sh 

}
cfg_section_SERVER () {
cfg_unset SERVER
user=( user )
pws=( password )
}
/home/milanbalazs/scripts/bash_ini_parser.sh: eval: line 65: syntax error near unexpected token `}'

Test run with my change (With an extra echo):

>>> ./test.sh 
cfg_section_SERVER () {
cfg_unset SERVER
user=( user )
pws=( password )
}
DONE

Conclusion:

  • As you can see above my change solves the wrong and unnecessary } character beginning of the structure of eval function.

If there is empty trailing line in the INI file you can get the following error:

eval: line 64: syntax error near unexpected token `}'

My change removes the empty lines from INI file.
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.

1 participant