summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonas Smedegaard <dr@jones.dk>2018-07-03 00:35:46 +0200
committerJonas Smedegaard <dr@jones.dk>2018-07-03 00:35:46 +0200
commit42cfe15a0c8be7da2f20fa4fa5e89c320f5c80d9 (patch)
treebe32c0ec423539ed4fdaa2d1a6d7aa11db340034
parent6df12d4e22d3526d420d4963ff7dfba039f42951 (diff)
Support execution from a distance (not only in current working directory).
-rwxr-xr-xbin/mycsv2ledger9
-rwxr-xr-xbin/mymerkur2csv4
2 files changed, 8 insertions, 5 deletions
diff --git a/bin/mycsv2ledger b/bin/mycsv2ledger
index d01ced6..f59e3e3 100755
--- a/bin/mycsv2ledger
+++ b/bin/mycsv2ledger
@@ -3,13 +3,14 @@
set -e
infile="$1"
+dirname=$(dirname "$infile")
basename=$(basename "$infile" .csv)
-outfile="${2:-$basename.ledger}"
-rulesfile="$basename.rules"
+outfile="${2:-$dirname/$basename.ledger}"
+rulesfile="$dirname/$basename.rules"
{
- find * -name "$infile.rules" -execdir cat '{}' +;
- find * -name "$basename.*.rules" \! -name "$infile.rules" -execdir cat '{}' +;
+ find * -wholename "$infile.rules" -execdir cat '{}' +;
+ find * -wholename "$basename.*.rules" \! -name "$infile.rules" -execdir cat '{}' +;
} > "$rulesfile"
hledger print --rules-file "$rulesfile" -f "$infile" > "$outfile"
rm "$rulesfile"
diff --git a/bin/mymerkur2csv b/bin/mymerkur2csv
index e4ffef4..f5da61f 100755
--- a/bin/mymerkur2csv
+++ b/bin/mymerkur2csv
@@ -3,6 +3,8 @@
set -e
infile="$1"
-outfile="${2:-$(basename "$infile" .csv)_out.csv}"
+dirname=$(dirname "$infile")
+basename=$(basename "$infile" .csv)
+outfile="${2:-$dirname/${basename}_out.csv}"
csvtool -t ";" -u COMMA square "$infile" > "$outfile"