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
18 import os, struct, subprocess, sys
20 sys.path[:0] = [os.path.dirname(os.path.realpath(__file__)) + '/..']
22 from bup import compat, options
23 from bup.helpers import debug1, debug2, mux
24 from bup.io import byte_stream
26 # Give the subcommand exclusive access to stdin.
27 orig_stdin = os.dup(0)
28 devnull = os.open(os.devnull, os.O_RDONLY)
33 bup mux command [arguments...]
36 o = options.Options(optspec)
37 opt, flags, extra = o.parse(compat.argv[1:])
39 o.fatal('command is required')
43 debug2('bup mux: starting %r\n' % (extra,))
45 outr, outw = os.pipe()
46 errr, errw = os.pipe()
51 p = subprocess.Popen(subcmd, stdin=orig_stdin, stdout=outw, stderr=errw,
52 close_fds=False, preexec_fn=close_fds)
56 out = byte_stream(sys.stdout)
59 mux(p, out.fileno(), outr, errr)
65 debug1('%s exited with code %d\n' % (extra[0], prv))
67 debug1('bup mux: done\n')