From 113963a89d3f5d2692a56007676b78104f6dfce7 Mon Sep 17 00:00:00 2001 From: Glenn Morris Date: Wed, 31 Jan 2018 15:05:14 -0500 Subject: [PATCH] automerge: add option to work in specific directory * admin/automerge (usage): Mention -d. (dir): New variable. (-d): New option. (main): If requested, cd to specified directory. --- admin/automerge | 32 +++++++++++++++++++++++--------- 1 file changed, 23 insertions(+), 9 deletions(-) diff --git a/admin/automerge b/admin/automerge index 218ecb067c7..6182ad01a55 100755 --- a/admin/automerge +++ b/admin/automerge @@ -28,6 +28,11 @@ ## Intended usage: ## Have a dedicated git directory just for this. ## Have a cron job that calls this script with -r -p. +## +## Modifying a running shell script can have unpredictable results, +## so the paranoid will first make a copy of this script, and then run +## it with the -d option to point to the repository directory, in case +## a pull updates this script while it is working. die () # write error to stderr and exit { @@ -40,20 +45,14 @@ PD=${0%/*} [ "$PD" = "$0" ] && PD=. # if PATH includes PWD -## This should be the admin directory. -cd $PD -cd ../ -[ -d admin ] || die "Could not locate admin directory" - -[ -e .git ] || die "No .git" - usage () { cat 1>&2 < /dev/null -- 2.39.2