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")/bup-python" || exit $?
13 exec "$bup_python" "$0"
17 from __future__ import absolute_import
18 import os, sys, subprocess, struct
20 from bup import compat, options
21 from bup.helpers import debug1, debug2, mux
22 from bup.io import byte_stream
24 # Give the subcommand exclusive access to stdin.
25 orig_stdin = os.dup(0)
26 devnull = os.open(os.devnull, os.O_RDONLY)
31 bup mux command [arguments...]
34 o = options.Options(optspec)
35 opt, flags, extra = o.parse(compat.argv[1:])
37 o.fatal('command is required')
41 debug2('bup mux: starting %r\n' % (extra,))
43 outr, outw = os.pipe()
44 errr, errw = os.pipe()
49 p = subprocess.Popen(subcmd, stdin=orig_stdin, stdout=outw, stderr=errw,
50 close_fds=False, preexec_fn=close_fds)
54 out = byte_stream(sys.stdout)
57 mux(p, out.fileno(), outr, errr)
63 debug1('%s exited with code %d\n' % (extra[0], prv))
65 debug1('bup mux: done\n')