]> arthur.barton.de Git - bup.git/commitdiff
ls: convert to internal command
authorRob Browning <rlb@defaultvalue.org>
Sat, 6 Feb 2021 18:52:35 +0000 (12:52 -0600)
committerRob Browning <rlb@defaultvalue.org>
Sat, 6 Mar 2021 18:29:38 +0000 (12:29 -0600)
Signed-off-by: Rob Browning <rlb@defaultvalue.org>
lib/bup/cmd/ls.py
lib/bup/ls.py
lib/cmd/bup
lib/cmd/ftp-cmd.py

index af70e07754f5fd03fefb6d978118fc6ba4d1133b..a7fc6dbeb243ff9cdeb016bd2d14d860b295f88a 100755 (executable)
@@ -1,33 +1,15 @@
-#!/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__)) + '/../..'
+from __future__ import absolute_import, print_function
+import os.path, sys
 
 from bup import compat, git, ls
 from bup.io import byte_stream
 
+def main(argv):
+    git.check_repo_or_die()
 
-git.check_repo_or_die()
-
-sys.stdout.flush()
-out = byte_stream(sys.stdout)
-# Check out lib/bup/ls.py for the opt spec
-rc = ls.via_cmdline(compat.argv[1:], out=out)
-sys.exit(rc)
+    sys.stdout.flush()
+    out = byte_stream(sys.stdout)
+    # Check out lib/bup/ls.py for the opt spec
+    rc = ls.via_cmdline(argv[1:], out=out)
+    sys.exit(rc)
index 8117bd76506eb66da342b4eb5dc9fe458c8e1fb8..9ea313352c9a4d0a618e3448947826af25dfb3e7 100644 (file)
@@ -78,9 +78,9 @@ def opts_from_cmdline(args, onabort=None):
 
     """
     if onabort:
-        opt, flags, extra = Options(optspec, onabort=onabort).parse(args)
+        opt, flags, extra = Options(optspec, onabort=onabort).parse_bytes(args)
     else:
-        opt, flags, extra = Options(optspec).parse(args)
+        opt, flags, extra = Options(optspec).parse_bytes(args)
 
     opt.paths = [argv_bytes(x) for x in extra] or (b'/',)
     opt.long_listing = opt.l
index c4e7bc5f4c5a37af8c3afb02b0b2d1b0fae60b9b..d50278b52846105ece999aff3c8997005092ae9f 100755 (executable)
@@ -185,7 +185,8 @@ if not subcmd_name:
     usage()
 
 try:
-    if subcmd_name not in (b'cat-file',):
+    if subcmd_name not in (b'cat-file',
+                           b'ls'):
         raise ModuleNotFoundError()
     cmd_module = import_module('bup.cmd.'
                                + subcmd_name.decode('ascii').replace('-', '_'))
index 275ecb2c51a9bb6735c89fa081593035e921721f..2878c8b6954bef56bd3d67a65ec2a837fe90cc30 100755 (executable)
@@ -42,8 +42,7 @@ class OptionError(Exception):
 
 def do_ls(repo, args, out):
     try:
-        opt = ls.opts_from_cmdline([fsdecode(arg) for arg in args],
-                                   onabort=OptionError)
+        opt = ls.opts_from_cmdline(args, onabort=OptionError)
     except OptionError as e:
         log('error: %s' % e)
         return