]> arthur.barton.de Git - bup.git/blobdiff - lib/cmd/init-cmd.py
Bypass Python 3 glibc argv problems by routing args through env
[bup.git] / lib / cmd / init-cmd.py
index ad2ed82877ab2bc643ee070f0ad7c75b5e5e959b..cff5c5cdd7ac3ba07762ffa1362099010bbc011b 100755 (executable)
@@ -1,14 +1,23 @@
 #!/bin/sh
 """": # -*-python-*-
+# https://sourceware.org/bugzilla/show_bug.cgi?id=26034
+export "BUP_ARGV_0"="$0"
+arg_i=1
+for arg in "$@"; do
+    export "BUP_ARGV_${arg_i}"="$arg"
+    shift
+    arg_i=$((arg_i + 1))
+done
+# Here to end of preamble replaced during install
 bup_python="$(dirname "$0")/bup-python" || exit $?
-exec "$bup_python" "$0" ${1+"$@"}
+exec "$bup_python" "$0"
 """
 # end of bup preamble
 
 from __future__ import absolute_import
 import sys
 
-from bup import git, options, client
+from bup import compat, git, options, client
 from bup.helpers import log, saved_errors
 from bup.compat import argv_bytes
 
@@ -19,7 +28,7 @@ optspec = """
 r,remote=  remote repository path
 """
 o = options.Options(optspec)
-(opt, flags, extra) = o.parse(sys.argv[1:])
+opt, flags, extra = o.parse(compat.argv[1:])
 
 if extra:
     o.fatal("no arguments expected")