]> arthur.barton.de Git - bup.git/blobdiff - lib/cmd/index-cmd.py
Bypass Python 3 glibc argv problems by routing args through env
[bup.git] / lib / cmd / index-cmd.py
index b131db990264b9079c2b41e1c2007d16075c01ff..030451e1339d8bcb9392d9558dccf0848c0934be 100755 (executable)
@@ -1,7 +1,16 @@
 #!/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
 
@@ -9,7 +18,7 @@ from __future__ import absolute_import, print_function
 from binascii import hexlify
 import sys, stat, time, os, errno, re
 
-from bup import metadata, options, git, index, drecurse, hlinkdb
+from bup import compat, metadata, options, git, index, drecurse, hlinkdb
 from bup.compat import argv_bytes
 from bup.drecurse import recursive_dirlist
 from bup.hashsplit import GIT_MODE_TREE, GIT_MODE_FILE
@@ -231,7 +240,7 @@ v,verbose  increase log output (can be used more than once)
 x,xdev,one-file-system  don't cross filesystem boundaries
 """
 o = options.Options(optspec)
-(opt, flags, extra) = o.parse(sys.argv[1:])
+opt, flags, extra = o.parse(compat.argv[1:])
 
 if not (opt.modified or \
         opt['print'] or \