about summary refs log tree commit diff
path: root/Src
diff options
context:
space:
mode:
Diffstat (limited to 'Src')
-rw-r--r--Src/builtin.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/Src/builtin.c b/Src/builtin.c
index e852092e2..003897bb4 100644
--- a/Src/builtin.c
+++ b/Src/builtin.c
@@ -3689,8 +3689,11 @@ bin_print(char *name, char **args, Options ops, int func)
     if (OPT_ISSET(ops,'o') || OPT_ISSET(ops,'O')) {
 	int flags;
 
-	if (fmt && !*args)
+	if (fmt && !*args) {
+	    if (fout != stdout)
+	        fclose(fout);
 	    return 0;
+	}
 	flags = OPT_ISSET(ops,'i') ? SORTIT_IGNORING_CASE : 0;
 	if (OPT_ISSET(ops,'O'))
 	    flags |= SORTIT_BACKWARDS;