aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorlinear <dev@linear.network>2021-09-05 00:34:07 -0700
committerFelix Queißner <felix@ib-queissner.de>2021-09-05 11:04:54 +0200
commit2cdf23f692ae9050f1f109162aeac82d37643748 (patch)
tree59bcba3f387dd2ae928fecdaae304c48e5826423
parente07c8eb599c9fc0f77c7a6f0643a786b751796b4 (diff)
doc/gen-man.sh: make sed command portable
usage of the "-i" feature of sed is not entirely portable across different operating systems. -i has an optional extension to save a backup of the edited file, and different systems parse this option in a different manner. the sed in GNU, busybox, NetBSD, and OpenBSD expects the argument to be immediately after, like `-i.bak`, if it is present. the sed in macOS and FreeBSD expects the argument to follow after a space, like `-i .bak`, but will accept the `-i.bak` form as well. the issue is that when no backup is specified, the first requires just `-i`, where the second requires `-i ''`. the easiest way around this is to just add a backup, which is what i chose to do here. i also added the .bak extension to the .gitignore. additionally, all aforementioned seds except for GNU require the file to be the final argument, and will not accept it between other options.
-rw-r--r--.gitignore1
-rwxr-xr-xdoc/gen-man.sh2
2 files changed, 2 insertions, 1 deletions
diff --git a/.gitignore b/.gitignore
index a7dfef2..4e09d79 100644
--- a/.gitignore
+++ b/.gitignore
@@ -8,6 +8,7 @@ doc/kristall.1
*~
*.autosave
*.a
+*.bak
*.core
*.moc
*.o
diff --git a/doc/gen-man.sh b/doc/gen-man.sh
index 8391c73..4463c5a 100755
--- a/doc/gen-man.sh
+++ b/doc/gen-man.sh
@@ -46,7 +46,7 @@ cp "$man_head" "$man_output"
# Insert last modified date (use last-modified date of help.gemini)
last_modified=$(date -r "$gemtext_in" +"%F")
-sed -i "$man_output" -e 's#\$(DATE)#'"$last_modified"'#g'
+sed -i'.bak' -e 's#\$(DATE)#'"$last_modified"'#g' "$man_output"
# Some pre-processing before giving our gemtext to the awk script.
gem_in=$(