X-Git-Url: https://arthur.barton.de/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=lib%2Fcmd%2Fftp-cmd.py;h=275ecb2c51a9bb6735c89fa081593035e921721f;hb=5e70a1c0d26d32866787369a38e07385da0de842;hp=30e523de940f5041e4282e9434e44ebfb2f32b32;hpb=77b44edd72a07505cfa0808fc6a0ac4306ae6306;p=bup.git diff --git a/lib/cmd/ftp-cmd.py b/lib/cmd/ftp-cmd.py index 30e523d..275ecb2 100755 --- a/lib/cmd/ftp-cmd.py +++ b/lib/cmd/ftp-cmd.py @@ -1,7 +1,16 @@ #!/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 @@ -11,10 +20,15 @@ exec "$bup_python" "$0" ${1+"$@"} # (e.g. ISO-8859-1). from __future__ import absolute_import, print_function -import sys, os, stat, fnmatch -from bup import _helpers, options, git, shquote, ls, vfs -from bup.compat import argv_bytes +# Intentionally replace the dirname "$0" that python prepends +import os, sys +sys.path[0] = os.path.dirname(os.path.realpath(__file__)) + '/..' + +import fnmatch, stat + +from bup import _helpers, compat, options, git, shquote, ls, vfs +from bup.compat import argv_bytes, fsdecode from bup.helpers import chunkyreader, handle_ctrl_c, log from bup.io import byte_stream, path_msg from bup.repo import LocalRepo @@ -28,7 +42,8 @@ class OptionError(Exception): def do_ls(repo, args, out): try: - opt = ls.opts_from_cmdline(args, onabort=OptionError) + opt = ls.opts_from_cmdline([fsdecode(arg) for arg in args], + onabort=OptionError) except OptionError as e: log('error: %s' % e) return @@ -43,11 +58,20 @@ def write_to_file(inf, outf): def inputiter(): if os.isatty(stdin.fileno()): while 1: - try: - yield _helpers.readline(b'bup> ') - except EOFError: - print() # Clear the line for the terminal's next prompt - break + if hasattr(_helpers, 'readline'): + try: + yield _helpers.readline(b'bup> ') + except EOFError: + print() # Clear the line for the terminal's next prompt + break + else: + out.write(b'bup> ') + out.flush() + read_line = stdin.readline() + if not read_line: + print('') + break + yield read_line else: for line in stdin: yield line @@ -115,7 +139,7 @@ optspec = """ bup ftp [commands...] """ o = options.Options(optspec) -(opt, flags, extra) = o.parse(sys.argv[1:]) +opt, flags, extra = o.parse(compat.argv[1:]) git.check_repo_or_die()