From 9ca319e34691cc3bc14f861fbdb0f44dddb8df06 Mon Sep 17 00:00:00 2001
From: Roland Hieber <rohieb@rohieb.name>
Date: Thu, 13 May 2021 23:32:57 +0200
Subject: [PATCH] scripts/vc: make it usable from different paths

---
 mv-protokolle/Makefile | 2 +-
 scripts/vc             | 6 ++++--
 2 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/mv-protokolle/Makefile b/mv-protokolle/Makefile
index a6435f0..cb12d0c 100644
--- a/mv-protokolle/Makefile
+++ b/mv-protokolle/Makefile
@@ -53,7 +53,7 @@ s0artcl.cls s0minutes.cls: stratum0-latex/stratum0-latex.ins stratum0-latex/s0ar
 	if [ ! -h s0minutes.cls ]; then ln -s stratum0-latex/s0minutes.cls . ; fi
 
 vc.tex: ../.git/index ../.git/HEAD ../scripts/vc ../scripts/vc-git.awk
-	cd ../scripts; sh ./vc -m && mv vc.tex ..
+	../scripts/vc -m
 
 %.pdf: %.tex vc.tex s0minutes.cls s0artcl.cls
 	$(latexmk) $(if $(PVC),-pvc,-pvc-) "$<"
diff --git a/scripts/vc b/scripts/vc
index 8e1988e..233a680 100755
--- a/scripts/vc
+++ b/scripts/vc
@@ -3,6 +3,8 @@
 # The original file can be found at CTAN:support/vc.
 # This file is Public Domain.
 
+selfdir=$(dirname "$(realpath -e "${0}")")
+
 # Parse command line options
 full=0
 mod=0
@@ -30,12 +32,12 @@ logformat="${logformat}CommitterEmail: %ce%n"
 logformat="${logformat}CommitterDate: %ci%n"
 LC_ALL=C
 git --no-pager log -1 HEAD --pretty=format:"$logformat" \
-	| gawk -v script=log -v full=$full -f vc-git.awk \
+	| gawk -v script=log -v full=$full -f "${selfdir}"/vc-git.awk \
 	> vc.tex
 
 # Query modification status of the working copy
 if [ "$mod" = 1 ]; then
 	git status --porcelain=v1 \
-		| gawk -v script=status -f vc-git.awk \
+		| gawk -v script=status -f "${selfdir}"/vc-git.awk \
 		>> vc.tex
 fi
-- 
GitLab