]> arthur.barton.de Git - bup.git/commitdiff
mux-cmd: copy to bup.cmd.mux
authorRob Browning <rlb@defaultvalue.org>
Fri, 12 Feb 2021 20:15:11 +0000 (14:15 -0600)
committerRob Browning <rlb@defaultvalue.org>
Sat, 6 Mar 2021 18:29:39 +0000 (12:29 -0600)
Signed-off-by: Rob Browning <rlb@defaultvalue.org>
lib/bup/cmd/mux.py [new file with mode: 0755]
lib/cmd/mux-cmd.py [deleted file]

diff --git a/lib/bup/cmd/mux.py b/lib/bup/cmd/mux.py
new file mode 100755 (executable)
index 0000000..3204bec
--- /dev/null
@@ -0,0 +1,72 @@
+#!/bin/sh
+"""": # -*-python-*-
+# 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
+
+# Intentionally replace the dirname "$0" that python prepends
+import os, sys
+sys.path[0] = os.path.dirname(os.path.realpath(__file__)) + '/../..'
+
+import struct, subprocess
+
+from bup import compat, options
+from bup.helpers import debug1, debug2, mux
+from bup.io import byte_stream
+
+# Give the subcommand exclusive access to stdin.
+orig_stdin = os.dup(0)
+devnull = os.open(os.devnull, os.O_RDONLY)
+os.dup2(devnull, 0)
+os.close(devnull)
+
+optspec = """
+bup mux command [arguments...]
+--
+"""
+o = options.Options(optspec)
+opt, flags, extra = o.parse(compat.argv[1:])
+if len(extra) < 1:
+    o.fatal('command is required')
+
+subcmd = extra
+
+debug2('bup mux: starting %r\n' % (extra,))
+
+outr, outw = os.pipe()
+errr, errw = os.pipe()
+def close_fds():
+    os.close(outr)
+    os.close(errr)
+
+p = subprocess.Popen(subcmd, stdin=orig_stdin, stdout=outw, stderr=errw,
+                     close_fds=False, preexec_fn=close_fds)
+os.close(outw)
+os.close(errw)
+sys.stdout.flush()
+out = byte_stream(sys.stdout)
+out.write(b'BUPMUX')
+out.flush()
+mux(p, out.fileno(), outr, errr)
+os.close(outr)
+os.close(errr)
+prv = p.wait()
+
+if prv:
+    debug1('%s exited with code %d\n' % (extra[0], prv))
+
+debug1('bup mux: done\n')
+
+sys.exit(prv)
diff --git a/lib/cmd/mux-cmd.py b/lib/cmd/mux-cmd.py
deleted file mode 100755 (executable)
index 64155e4..0000000
+++ /dev/null
@@ -1,72 +0,0 @@
-#!/bin/sh
-"""": # -*-python-*-
-# 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
-
-# Intentionally replace the dirname "$0" that python prepends
-import os, sys
-sys.path[0] = os.path.dirname(os.path.realpath(__file__)) + '/..'
-
-import struct, subprocess
-
-from bup import compat, options
-from bup.helpers import debug1, debug2, mux
-from bup.io import byte_stream
-
-# Give the subcommand exclusive access to stdin.
-orig_stdin = os.dup(0)
-devnull = os.open(os.devnull, os.O_RDONLY)
-os.dup2(devnull, 0)
-os.close(devnull)
-
-optspec = """
-bup mux command [arguments...]
---
-"""
-o = options.Options(optspec)
-opt, flags, extra = o.parse(compat.argv[1:])
-if len(extra) < 1:
-    o.fatal('command is required')
-
-subcmd = extra
-
-debug2('bup mux: starting %r\n' % (extra,))
-
-outr, outw = os.pipe()
-errr, errw = os.pipe()
-def close_fds():
-    os.close(outr)
-    os.close(errr)
-
-p = subprocess.Popen(subcmd, stdin=orig_stdin, stdout=outw, stderr=errw,
-                     close_fds=False, preexec_fn=close_fds)
-os.close(outw)
-os.close(errw)
-sys.stdout.flush()
-out = byte_stream(sys.stdout)
-out.write(b'BUPMUX')
-out.flush()
-mux(p, out.fileno(), outr, errr)
-os.close(outr)
-os.close(errr)
-prv = p.wait()
-
-if prv:
-    debug1('%s exited with code %d\n' % (extra[0], prv))
-
-debug1('bup mux: done\n')
-
-sys.exit(prv)