From 12f0b138c93f3f544233aeb531dfa84a5dd75e61 Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Wed, 9 Oct 2013 03:31:14 +0200 Subject: m readme + implement -0 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- README | 6 +++++- src/bfind.py | 3 +++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/README b/README index d0f6ef6..bf0c6a5 100644 --- a/README +++ b/README @@ -16,9 +16,13 @@ symlinks points, and directories will never be revisited. Visited directories will be memorised by absolute real path name. -With --visible not files starting with a dot +With --visible no files starting with a dot will be listed. +With --print0 a NUL (\0) character will be +printed at end of file names rather than +a LF (\n). + Short option alternatives: diff --git a/src/bfind.py b/src/bfind.py index bb8e3af..6dc67d9 100755 --- a/src/bfind.py +++ b/src/bfind.py @@ -25,6 +25,7 @@ xdev = False hardlinks = False symlinks = False visible = False +ending = '\n'.encode('utf-8') path = '' for arg in sys.argv[1:]: @@ -35,6 +36,7 @@ for arg in sys.argv[1:]: if arg == '--hardlinks' or (arg[:2] != '--' and 'h' in arg): hardlinks = True if arg == '--symlinks' or (arg[:2] != '--' and 's' in arg): symlinks = True if arg == '--visible' or (arg[:2] != '--' and 'v' in arg): visible = True + if arg == '--print0' or (arg[:2] != '--' and '0' in arg): ending = '\0'.encode('utf-8') visited_name = set() visited_id = set() @@ -65,6 +67,7 @@ while len(queue) > 0: if os.stat(path).st_dev != start_dev: # TODO make sure there is not symlinking problems continue sys.stdout.buffer.write(path.encode('utf-8')) + sys.stdout.buffer.write(ending) sys.stdout.buffer.flush() if os.path.isdir(path) and (symlinks or not os.path.islink(path)): for subd in os.listdir(path): -- cgit v1.2.3-70-g09d2