summaryrefslogtreecommitdiff
path: root/standalone
diff options
context:
space:
mode:
authorGravatar Joey Hess <joeyh@joeyh.name>2015-08-04 16:08:19 -0400
committerGravatar Joey Hess <joeyh@joeyh.name>2015-08-04 16:08:19 -0400
commita16438a99ba92677dd4527c0add39fbc2a806a3e (patch)
tree45468a2b01b8218cdac7eec68e9f13d5e72de8ca /standalone
parenteeab166e1bed5f654acc75d55fa62394a16cbd2d (diff)
Linux standalone: Work around problem that prevented it from working properly if unpacked into a directory that contains ":" or ";" in its name.
Diffstat (limited to 'standalone')
-rwxr-xr-xstandalone/linux/skel/runshell25
1 files changed, 23 insertions, 2 deletions
diff --git a/standalone/linux/skel/runshell b/standalone/linux/skel/runshell
index b1f36f064..b540c983b 100755
--- a/standalone/linux/skel/runshell
+++ b/standalone/linux/skel/runshell
@@ -26,6 +26,22 @@ cd "$base"
base="$(pwd)"
cd "$orig"
+# --library-path won't work if $base contains : or ;
+# Detect this problem, and work around it by using a temp directory.
+if echo "$base" | grep -q '[:;]'; then
+ tbase=$(mktemp -d -p /tmp annexshimXXXXXXXXX 2>/dev/null || true)
+ if [ -z "$tbase" ]; then
+ tbase="/tmp/annexshim.$$"
+ mkdir "$tbase"
+ fi
+ ln -s "$base" "$tbase/link"
+ base="$tbase/link"
+ cleanuptbase () {
+ rm -rf "$tbase"
+ }
+ trap cleanuptbase EXIT
+fi
+
# Install shim that's used to run git-annex-shell from ssh authorized_keys.
# The assistant also does this when run, but the user may not be using the
# assistant.
@@ -63,7 +79,7 @@ export ORIG_PATH
PATH="$base/bin:$PATH"
export PATH
-# This is used by the shim wrapper around each binary.
+# These env vars are used by the shim wrapper around each binary.
for lib in $(cat "$base/libdirs"); do
GIT_ANNEX_LD_LIBRARY_PATH="$base/$lib:$GIT_ANNEX_LD_LIBRARY_PATH"
done
@@ -103,7 +119,12 @@ export GIT_ANNEX_STANDLONE_ENV
if [ "$1" ]; then
cmd="$1"
shift 1
- exec "$cmd" "$@"
+ if [ -z "$tbase" ]; then
+ exec "$cmd" "$@"
+ else
+ # allow EXIT trap to cleanup
+ "$cmd" "$@"
+ fi
else
sh
fi