]> arthur.barton.de Git - bup.git/blobdiff - lib/cmd/restore-cmd.py
Prefer python 3, and mention intent to drop python 2 support
[bup.git] / lib / cmd / restore-cmd.py
index a5993638eaab1cb3380892953661c8e27907c1e2..37977248c45989707021c77000ed5e7544f67052 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
 from stat import S_ISDIR
-import copy, errno, os, sys, stat, re
+import copy, errno, os, re, stat, sys
 
-from bup import options, git, metadata, vfs
+sys.path[:0] = [os.path.dirname(os.path.realpath(__file__)) + '/..']
+
+from bup import compat, options, git, metadata, vfs
 from bup._helpers import write_sparsely
 from bup.compat import argv_bytes, fsencode, wrap_main
 from bup.helpers import (add_error, chunkyreader, die_if_errors, handle_ctrl_c,
@@ -181,7 +192,7 @@ def restore(repo, parent_path, name, item, top, sparse, numeric_ids, owner_map,
             out.write(b'%s@ -> %s\n' % (fullname, meta.symlink_target))
     else:
         if verbosity >= 2:
-            out.write(fullname + '\n')
+            out.write(fullname + b'\n')
 
     orig_cwd = os.getcwd()
     try:
@@ -225,7 +236,7 @@ def restore(repo, parent_path, name, item, top, sparse, numeric_ids, owner_map,
 
 def main():
     o = options.Options(optspec)
-    opt, flags, extra = o.parse(sys.argv[1:])
+    opt, flags, extra = o.parse(compat.argv[1:])
     verbosity = (opt.verbose or 0) if not opt.quiet else -1
     if opt.remote:
         opt.remote = argv_bytes(opt.remote)