]> arthur.barton.de Git - bup.git/blobdiff - t/echo-argv-bytes
Bypass Python 3 glibc argv problems by routing args through env
[bup.git] / t / echo-argv-bytes
index 99a145ef0b9a7f8a1d30d9753887863d9c7e9d90..66c5c6361cc122c70a8670957e04601e1b6245d9 100755 (executable)
@@ -1,7 +1,15 @@
 #!/bin/sh
 """": # -*-python-*-
-bup_python="$(dirname "$0")/../cmd/bup-python" || exit $?
-exec "$bup_python" "$0" ${1+"$@"}
+# 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
+bup_python="$(dirname "$0")/../lib/cmd/bup-python" || exit $?
+exec "$bup_python" "$0"
 """
 # end of bup preamble
 
@@ -11,11 +19,11 @@ from os.path import abspath, dirname
 from sys import stdout
 import os, sys
 
-script_home = abspath(dirname(sys.argv[0] or '.'))
+script_home = abspath(dirname(__file__))
 sys.path[:0] = [abspath(script_home + '/../lib'), abspath(script_home + '/..')]
 
-from bup.compat import argv_bytes
+from bup import compat
 
-for arg in [argv_bytes(x) for x in sys.argv]:
+for arg in compat.argvb:
     os.write(stdout.fileno(), arg)
     os.write(stdout.fileno(), b'\0\n')