From 6de3bc2ab64209ad7d5f54bacb19dad1008becd7 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Fri, 27 Dec 2013 14:30:00 -0400 Subject: [PATCH] make directory absolute (mostly as an example of using SETCONFIG) --- doc/special_remotes/external/example.sh | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/doc/special_remotes/external/example.sh b/doc/special_remotes/external/example.sh index 60425dfac9..97f8a2813b 100755 --- a/doc/special_remotes/external/example.sh +++ b/doc/special_remotes/external/example.sh @@ -21,6 +21,11 @@ getconfig () { ask GETCONFIG "$1" } +# Stores a value in the remote's configuration. +setconfig () { + echo SETCONFIG "$1" "$2" +} + # Sets LOC to the location to use to store a key. calclocation () { ask DIRHASH "$1" @@ -60,13 +65,20 @@ while read line; do # (Note that this is not run every time, only when # git annex initremote or git annex enableremote is # run.) + getconfig directory - mydirectory="$RET" + # Input directory could be relative; make it + # absolute, and store that. + mydirectory="$(readlink -f "$RET")" + setconfig directory "$mydirectory" if [ -z "$mydirectory" ]; then echo INITREMOTE-FAILURE "You need to set directory=" else - mkdir -p "$mydirectory" - echo INITREMOTE-SUCCESS + if mkdir -p "$mydirectory"; then + echo INITREMOTE-SUCCESS + else + echo INITREMOTE-FAILURE "Failed to write to $mydirectory" + fi fi ;; PREPARE)