aboutsummaryrefslogtreecommitdiff
path: root/git/set
diff options
context:
space:
mode:
Diffstat (limited to 'git/set')
-rwxr-xr-xgit/set21
1 files changed, 21 insertions, 0 deletions
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