aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMattias Andrée <maandree@operamail.com>2013-10-09 03:31:14 +0200
committerMattias Andrée <maandree@operamail.com>2013-10-09 03:31:14 +0200
commit12f0b138c93f3f544233aeb531dfa84a5dd75e61 (patch)
treeb21ac2ebe10b8779950cf41a55ec1146a1888b42
parentadd --print0 to readme (diff)
downloadbfind-12f0b138c93f3f544233aeb531dfa84a5dd75e61.tar.gz
bfind-12f0b138c93f3f544233aeb531dfa84a5dd75e61.tar.bz2
bfind-12f0b138c93f3f544233aeb531dfa84a5dd75e61.tar.xz
m readme + implement -0
Signed-off-by: Mattias Andrée <maandree@operamail.com>
-rw-r--r--README6
-rwxr-xr-xsrc/bfind.py3
2 files changed, 8 insertions, 1 deletions
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):