From f2e4ad448284b574d3120e0b9aabeed65299e16b Mon Sep 17 00:00:00 2001 From: Nikita Ivanov Date: Fri, 15 Jul 2022 00:00:52 +0500 Subject: [PATCH] Cleanup --- Makefile | 4 ++-- deplistadd.sh => deptable/insert.sh | 9 +++++++-- deplist.awk => deptable/list.awk | 0 deplist.md.sh => deptable/markdown.sh | 0 deplist.1.sh => deptable/roff.sh | 0 5 files changed, 9 insertions(+), 4 deletions(-) rename deplistadd.sh => deptable/insert.sh (68%) rename deplist.awk => deptable/list.awk (100%) rename deplist.md.sh => deptable/markdown.sh (100%) rename deplist.1.sh => deptable/roff.sh (100%) diff --git a/Makefile b/Makefile index 8a7466e..b1c85c2 100644 --- a/Makefile +++ b/Makefile @@ -39,8 +39,8 @@ clean: $(MAKE) -C embed clean docs: README.md doc/ctpv.1 - ./deplist.awk $(PRE) | ./deplist.md.sh | ./deplistadd.sh README.md - ./deplist.awk $(PRE) | ./deplist.1.sh | ./deplistadd.sh doc/ctpv.1 + deptable/list.awk $(PRE) | deptable/markdown.sh | deptable/insert.sh README.md + deptable/list.awk $(PRE) | deptable/roff.sh | deptable/insert.sh doc/ctpv.1 ctpv: $(OBJ) $(CC) -o $@ $+ $(LDFLAGS) diff --git a/deplistadd.sh b/deptable/insert.sh similarity index 68% rename from deplistadd.sh rename to deptable/insert.sh index 4fe3f07..4615042 100755 --- a/deplistadd.sh +++ b/deptable/insert.sh @@ -1,11 +1,14 @@ #!/bin/sh +set -e + +tmp="$(mktemp XXXXXX)" table="$(mktemp XXXXXX)" trap 'rm "$table"' EXIT cat > "$table" -sed -i " +sed " /TABLESTART/,/TABLEEND/ { /TABLESTART/ { r $table @@ -13,4 +16,6 @@ sed -i " } /TABLEEND/!d } -" "$1" +" "$1" > "$tmp" + +mv -- "$tmp" "$1" diff --git a/deplist.awk b/deptable/list.awk similarity index 100% rename from deplist.awk rename to deptable/list.awk diff --git a/deplist.md.sh b/deptable/markdown.sh similarity index 100% rename from deplist.md.sh rename to deptable/markdown.sh diff --git a/deplist.1.sh b/deptable/roff.sh similarity index 100% rename from deplist.1.sh rename to deptable/roff.sh