]> arthur.barton.de Git - bup.git/blobdiff - lib/cmd/drecurse-cmd.py
Prefer python 3, and mention intent to drop python 2 support
[bup.git] / lib / cmd / drecurse-cmd.py
index 3fa155fdd27548a748ac8890a9083cdd6045a4a6..1c6791832741186238c1151e1b57943805cb1ba1 100755 (executable)
@@ -1,15 +1,26 @@
 #!/bin/sh
 """": # -*-python-*-
-bup_python="$(dirname "$0")/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
+# Here to end of preamble replaced during install
+bup_python="$(dirname "$0")/../../config/bin/python" || exit $?
+exec "$bup_python" "$0"
 """
 # end of bup preamble
 
 from __future__ import absolute_import, print_function
 from os.path import relpath
-import sys
+import os.path, sys
 
-from bup import options, drecurse
+sys.path[:0] = [os.path.dirname(os.path.realpath(__file__)) + '/..']
+
+from bup import compat, options, drecurse
 from bup.compat import argv_bytes
 from bup.helpers import log, parse_excludes, parse_rx_excludes, saved_errors
 from bup.io import byte_stream
@@ -27,7 +38,7 @@ q,quiet  don't actually print filenames
 profile  run under the python profiler
 """
 o = options.Options(optspec)
-(opt, flags, extra) = o.parse(sys.argv[1:])
+opt, flags, extra = o.parse(compat.argv[1:])
 
 if len(extra) != 1:
     o.fatal("exactly one filename expected")