Merge pull request #326 into master
All checks were successful
docker-finance / all (push) Successful in 39m44s

38b2633e container: hledger-flow: lib_preprocess: add custom delim when testing (Aaron Fiore)
e3598fce container: hledger-flow: lib_preprocess: bash quote given column(s) (Aaron Fiore)
This commit was merged in pull request #326.
This commit is contained in:
2026-03-18 09:43:16 -07:00

View File

@@ -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