From 67c542b79a3cb1d20dd2ff44a69c10898b157da5 Mon Sep 17 00:00:00 2001 From: Milan Balazs Date: Thu, 4 Aug 2022 10:05:03 +0200 Subject: [PATCH] Fix the "eval" error due to empty lines in the INI file 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. --- bash-ini-parser | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/bash-ini-parser b/bash-ini-parser index 3daf302..7a1c1f8 100755 --- a/bash-ini-parser +++ b/bash-ini-parser @@ -22,8 +22,9 @@ function cfg_parser { then shopt -s extglob fi - ini="$(<$1)" # read the file - ini=${ini//$'\r'/} # remove linefeed i.e dos2unix + ini="$(<$1)" # read the file + ini=${ini//$'\r'/} # remove linefeed i.e dos2unix + ini=$(echo "${ini}" | awk NF) # Remove the empty lines. ini="${ini//[/\\[}" debug "escaped ["