3 # https://sourceware.org/bugzilla/show_bug.cgi?id=26034
4 export "BUP_ARGV_0"="$0"
7 export "BUP_ARGV_${arg_i}"="$arg"
11 # Here to end of preamble replaced during install
12 bup_python="$(dirname "$0")/../../config/bin/python" || exit $?
13 exec "$bup_python" "$0"
17 from __future__ import absolute_import
19 # Intentionally replace the dirname "$0" that python prepends
21 sys.path[0] = os.path.dirname(os.path.realpath(__file__)) + '/..'
23 import struct, subprocess
25 from bup import compat, options
26 from bup.helpers import debug1, debug2, mux
27 from bup.io import byte_stream
29 # Give the subcommand exclusive access to stdin.
30 orig_stdin = os.dup(0)
31 devnull = os.open(os.devnull, os.O_RDONLY)
36 bup mux command [arguments...]
39 o = options.Options(optspec)
40 opt, flags, extra = o.parse(compat.argv[1:])
42 o.fatal('command is required')
46 debug2('bup mux: starting %r\n' % (extra,))
48 outr, outw = os.pipe()
49 errr, errw = os.pipe()
54 p = subprocess.Popen(subcmd, stdin=orig_stdin, stdout=outw, stderr=errw,
55 close_fds=False, preexec_fn=close_fds)
59 out = byte_stream(sys.stdout)
62 mux(p, out.fileno(), outr, errr)
68 debug1('%s exited with code %d\n' % (extra[0], prv))
70 debug1('bup mux: done\n')