Skip to content

Commit 458003a

Browse files
author
Jonathan Kamens
committed
lsdel and expunge shouldn't output extra blank lines
When lsdel and expunge list files they shouldn't output a blank line when there are no files to list.
1 parent 6b72eb8 commit 458003a

File tree

3 files changed

+9
-6
lines changed

3 files changed

+9
-6
lines changed

expunge

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,10 @@ def expunge(deleted_files, options):
4343
errors = 0
4444
if options.listfiles:
4545
print header
46-
print libdelete.format_columns(sorted(
46+
sys.stdout.write(libdelete.format_columns(
47+
sorted(
4748
[libdelete.relpath(
48-
libdelete.undeleted_name(x)) for x in deleted_files]))
49+
libdelete.undeleted_name(x)) for x in deleted_files])))
4950
print footer
5051
if not options.force and \
5152
not ask(confirmation, nowhoami=True):

libdelete.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ def format_columns(items, singlecol=False, width=80):
7979
rv = []
8080
for c in chunks(items, n_cols):
8181
rv.append("".join(item.ljust(col_width + padding) for item in c))
82-
return "\n".join(rv)
82+
return "\n".join(rv) + "\n" if rv else ""
8383

8484

8585
def have_AFS():

lsdel

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,10 +71,12 @@ def main():
7171
perror(e.message)
7272
rv = 1
7373

74-
print libdelete.format_columns(sorted(
74+
sys.stdout.write(libdelete.format_columns(
75+
sorted(
7576
[libdelete.relpath(
76-
libdelete.undeleted_name(x)) for x in deleted_files]),
77-
options.singlecolumn)
77+
libdelete.undeleted_name(x)) for x in deleted_files]),
78+
options.singlecolumn))
79+
7880
if options.yieldsize:
7981
total = None
8082
try:

0 commit comments

Comments
 (0)