2019-10-12 12:00:14 +03:00
|
|
|
#!/bin/bash
|
|
|
|
#
|
|
|
|
# This scripts expects stdin formatted like this:
|
|
|
|
# <multi-line csv file>
|
|
|
|
# RULES
|
|
|
|
# <multi-line rules>
|
|
|
|
#
|
2020-03-08 00:59:53 +03:00
|
|
|
awk -v CSV="t.$$.csv" -v RULES="t.$$.csv.rules" '
|
2019-10-12 12:00:14 +03:00
|
|
|
BEGIN{output=CSV}
|
|
|
|
/^RULES/{output=RULES}
|
|
|
|
!/^RULES/{print $0 >output}'
|
|
|
|
|
|
|
|
trap "rm -f t.$$.csv t.$$.csv.rules" EXIT ERR
|
|
|
|
|
2020-06-18 02:58:49 +03:00
|
|
|
# Remove variable file name from error messages
|
|
|
|
:; ( hledger -f csv:t.$$.csv --rules-file t.$$.csv.rules print "$@" ) \
|
2020-06-23 01:44:49 +03:00
|
|
|
2> >( sed -Ee "s/t.*.csv/input/" >&2 )
|