aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Ankarström <john@ankarstrom.se>2021-07-21 13:45:00 +0200
committerJohn Ankarström <john@ankarstrom.se>2021-07-21 13:45:00 +0200
commit10706a55adb3c5f12fb1438ef9990ee01b9266d2 (patch)
tree58e447a42ae6c6fddcd4d95c101a23040a8ca8ae
parent003f1a28b52ef0322975329d086920cf24828ac7 (diff)
downloadrbsd-10706a55adb3c5f12fb1438ef9990ee01b9266d2.tar.gz
Remove /git/sec, create more general /git/set instead
-rwxr-xr-xgit/sec19
-rwxr-xr-xgit/set21
2 files changed, 21 insertions, 19 deletions
diff --git a/git/sec b/git/sec
deleted file mode 100755
index 01b1e34..0000000
--- a/git/sec
+++ /dev/null
@@ -1,19 +0,0 @@
-#!/bin/sh -e
-
-sec=$1
-shift
-
-if [ -e "$sec" ] || [ -z "$sec" ]; then
- echo "usage: $0 section dir ..." 1>&2
- exit 1
-fi
-
-for d in "$@"; do
- if [ -e "$d"/cgitrc ]; then
- grep ^section= "$d"/cgitrc >/dev/null &&
- sed -i 's/^section=.*/section='"$sec"'/' "$d"/cgitrc ||
- echo section="$sec" >> "$d"/cgitrc
- else
- echo section="$sec" > "$d"/cgitrc
- fi
-done
diff --git a/git/set b/git/set
new file mode 100755
index 0000000..b8100e3
--- /dev/null
+++ b/git/set
@@ -0,0 +1,21 @@
+#!/bin/sh -e
+
+setting=$1
+shift
+value=$1
+shift
+
+if [ $# -eq 0 ]; then
+ echo "usage: $0 setting value dir ..." 1>&2
+ exit 1
+fi
+
+for d in "$@"; do
+ if [ -e "$d"/cgitrc ]; then
+ grep ^"$setting"= "$d"/cgitrc >/dev/null &&
+ sed -i "s ^$setting=.* $setting=$value " "$d"/cgitrc ||
+ echo "$setting=$value" >> "$d"/cgitrc
+ else
+ echo "$setting=$value" > "$d"/cgitrc
+ fi
+done