summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLars Wirzenius <liw@liw.fi>2012-02-25 14:27:43 +0000
committerLars Wirzenius <liw@liw.fi>2012-02-25 14:27:43 +0000
commit907faf600f4d95eaae4b5c2fc0e8bc06c3efe48e (patch)
tree79ca1d60da3f85738f4a1cbc890811c99628dbdd
parenta4a011dd30194eb3f1af728a887199d99da7ec29 (diff)
downloadsummain-907faf600f4d95eaae4b5c2fc0e8bc06c3efe48e.tar.gz
Do not recurse through a symlink given as root
-rwxr-xr-xsummain2
-rwxr-xr-xtests/symlink.script10
-rw-r--r--tests/symlink.stdout7
3 files changed, 18 insertions, 1 deletions
diff --git a/summain b/summain
index a9e7ead..b82c108 100755
--- a/summain
+++ b/summain
@@ -122,7 +122,7 @@ class Summain(cliapp.Application):
'choose output format (rfc822, csv, json)')
def files(self, root):
- if os.path.isdir(root):
+ if os.path.isdir(root) and not os.path.islink(root):
for dirname, dirnames, filenames in os.walk(root):
yield dirname
dirnames.sort()
diff --git a/tests/symlink.script b/tests/symlink.script
new file mode 100755
index 0000000..d5dd25e
--- /dev/null
+++ b/tests/symlink.script
@@ -0,0 +1,10 @@
+#!/bin/sh
+
+set -e
+
+mkdir "$DATADIR/dir"
+touch "$DATADIR/dir/file"
+ln -s dir "$DATADIR/symlink"
+./summain --exclude=mtime --exclude=uid --exclude=username \
+ --exclude=gid --exclude=group --exclude=mode "$DATADIR/symlink" |
+sed 's,^Name: /.*/,Name: ,'
diff --git a/tests/symlink.stdout b/tests/symlink.stdout
new file mode 100644
index 0000000..8288ba8
--- /dev/null
+++ b/tests/symlink.stdout
@@ -0,0 +1,7 @@
+Name: symlink
+Ino: 1
+Dev: 1
+Nlink: 1
+Size: 3
+Target: dir
+