diff --git a/container/src/hledger-flow/lib/lib_preprocess.bash b/container/src/hledger-flow/lib/lib_preprocess.bash index 9a8d7f8..35421b0 100755 --- a/container/src/hledger-flow/lib/lib_preprocess.bash +++ b/container/src/hledger-flow/lib/lib_preprocess.bash @@ -2,7 +2,7 @@ # docker-finance | modern accounting for the power-user # -# Copyright (C) 2021-2025 Aaron Fiore (Founder, Evergreen Crypto LLC) +# Copyright (C) 2021-2026 Aaron Fiore (Founder, Evergreen Crypto LLC) # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -64,9 +64,16 @@ echo -e " \e[32m│ └─\e[37;2m ${global_in_filename}\e[0m" function lib_preprocess::test_header() { local _column="$1" + local _header _header="$(lib_preprocess::__sanitize_header $2)" - [[ "$_header" =~ (^${_column}$|^${_column},|,${_column},|,${_column}$) ]] && return 0 || return 2 + + local _delim="$3" + [ -z "$_delim" ] && _delim="," + + # TODO: consolidate regexp + [[ "$_header" =~ (^"${_column}"$|^"${_column}${_delim}"|"${_delim}${_column}${_delim}"|"${_delim}${_column}"$) ]] \ + && return 0 || return 2 } # Assert header in given CSV header