From 55788d34ff6f7e8e3cefd068fe7ac2e9cd3db14d Mon Sep 17 00:00:00 2001 From: Darren 'Tadgy' Austin Date: Sun, 21 Jul 2019 15:10:25 +0100 Subject: [PATCH] Handle DOS format files correctly. Thanks to dive for the report :) --- parse_ini | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/parse_ini b/parse_ini index cfcfd0a..6f1863c 100755 --- a/parse_ini +++ b/parse_ini @@ -346,8 +346,8 @@ parse_ini() { # Ignore the line if it's a comment. [[ "$LINE" =~ ^[[:blank:]]*([$COMMENT_CHARS].*)*$ ]] && continue - # Strip the trailing whitespace from the line (leading whitespace has already been stripped by read). - LINE="${LINE/%*([[:blank:]])/}" + # Strip the trailing whitespace and any \r from the line (leading whitespace has already been stripped by read). + LINE="${LINE/%*([[:blank:]])*([$'\r'])/}" # Process the line. if [[ "${LINE:0:1}" == "[" ]]; then # Found the beginning of a section definition.