]> arthur.barton.de Git - bup.git/blobdiff - cmd/python-cmd.sh
Adjust rm-cmd and bup.rm for python 3 and enable test-rm
[bup.git] / cmd / python-cmd.sh
index 30a843487d28dd3e1b449b2917032dc7e40853b1..3cedf2ddf0785577b6d2eba46720ca113c15d46a 100644 (file)
@@ -13,28 +13,36 @@ done
 script_home="$(cd "$(dirname "$cmdpath")" && pwd -P)"
 cd "$top"
 
+bup_libdir="$script_home/../lib"  # bup_libdir will be adjusted during install
+export PYTHONPATH="$bup_libdir${PYTHONPATH:+:$PYTHONPATH}"
+
 # Force python to use ISO-8859-1 (aka Latin 1), a single-byte
 # encoding, to help avoid any manipulation of data from system APIs
 # (paths, users, groups, command line arguments, etc.)
 
-# Preserve for selective use
-if [ "${LC_CTYPE+x}" ]; then export BUP_LC_CTYPE="$LC_CTYPE"; fi
-if [ "${LC_ALL+x}" ]; then
-    export BUP_LC_ALL="$LC_ALL"
-    export LC_COLLATE="$LC_ALL"
-    export LC_MONETARY="$LC_ALL"
-    export LC_NUMERIC="$LC_ALL"
-    export LC_TIME="$LC_ALL"
-    export LC_MESSAGES="$LC_ALL"
-    unset LC_ALL
-fi
-
 export PYTHONCOERCECLOCALE=0  # Perhaps not necessary, but shouldn't hurt
-export LC_CTYPE=ISO-8859-1
 
-bup_libdir="$script_home/../lib"  # bup_libdir will be adjusted during install
-
-export PYTHONPATH="$bup_libdir${PYTHONPATH:+:$PYTHONPATH}"
-export BUP_RESOURCE_PATH="$bup_libdir"
+# We can't just export LC_CTYPE directly here because the locale might
+# not exist outside python, and then bash (at least) may be cranky.
 
-# This last line will be replaced with 'exec some/python "$@"
+if [ "${LC_ALL+x}" ]; then
+    unset LC_ALL
+    exec env \
+         BUP_LC_ALL="$LC_ALL" \
+         LC_COLLATE="$LC_ALL" \
+         LC_MONETARY="$LC_ALL" \
+         LC_NUMERIC="$LC_ALL" \
+         LC_TIME="$LC_ALL" \
+         LC_MESSAGES="$LC_ALL" \
+         LC_CTYPE=ISO-8859-1 \
+         @bup_python@ "$@"
+elif [ "${LC_CTYPE+x}" ]; then
+    exec env \
+         BUP_LC_CTYPE="$LC_CTYPE" \
+         LC_CTYPE=ISO-8859-1 \
+         @bup_python@ "$@"
+else
+    exec env \
+         LC_CTYPE=ISO-8859-1 \
+         @bup_python@ "$@"
+fi