Index: uspace/app/bdsh/cmds/modules/ls/ls.c
===================================================================
--- uspace/app/bdsh/cmds/modules/ls/ls.c	(revision c7afdf7aeb7a9b267482b637a8124172e3357f16)
+++ uspace/app/bdsh/cmds/modules/ls/ls.c	(revision f4f4b95e62a33cdf2a50bf7841b07ccb8ade8dff)
@@ -66,6 +66,6 @@
 /* Prototypes for the ls command, excluding entry points. */
 static unsigned int ls_start(ls_job_t *);
-static void ls_print(struct dir_elem_t *);
-static void ls_print_single_column(struct dir_elem_t *);
+static bool ls_print(struct dir_elem_t *);
+static bool ls_print_single_column(struct dir_elem_t *);
 static int ls_cmp_type_name(const void *, const void *);
 static int ls_cmp_name(const void *, const void *);
@@ -96,10 +96,12 @@
  * @param de		Directory element.
  */
-static void ls_print(struct dir_elem_t *de)
+static bool ls_print(struct dir_elem_t *de)
 {
 	int width = 13;
 
 	if (de->s.is_file) {
-		if (!ls.exact_size) {
+		if (ls.exact_size) {
+			printf("%-40s\t%*llu\n", de->name, width, (long long) de->s.size);
+		} else {
 			cap_spec_t cap;
 
@@ -114,19 +116,16 @@
 
 				printf("%-40s\t%*s %2s\n", de->name, width - 3, bytes, suffix);
-				
-				//if there is a failure with cap_format we simply print out an unformatted size
-				return;
-			}
-
-		}
-
-		printf("%-40s\t%*llu\n", de->name, width, (long long) de->s.size);
+			} else
+				return false;
+		}
 	} else if (de->s.is_directory)
 		printf("%-40s\t%*s\n", de->name, width, "<dir>");
 	else
 		printf("%-40s\n", de->name);
-}
-
-static void ls_print_single_column(struct dir_elem_t *de)
+
+	return true;
+}
+
+static bool ls_print_single_column(struct dir_elem_t *de)
 {
 	if (de->s.is_file) {
@@ -135,4 +134,6 @@
 		printf("%s/\n", de->name);
 	}
+
+	return true;
 }
 
@@ -251,6 +252,10 @@
 	}
 
-	for (i = 0; i < nbdirs; i++)
-		ls.printer(&tosort[i]);
+	for (i = 0; i < nbdirs; i++) {
+		if (!ls.printer(&tosort[i])) {
+			cli_error(CL_ENOMEM, "%s: Out of memory", cmdname);
+			goto out;
+		}
+	}
 
 	/* Populate the directory list. */
@@ -465,5 +470,8 @@
 	switch (scope) {
 	case LS_FILE:
-		ls.printer(&de);
+		if (!ls.printer(&de)) {
+			cli_error(CL_ENOMEM, "%s: Out of memory", cmdname);
+			return CMD_FAILURE;
+		}
 		break;
 	case LS_DIR:
Index: uspace/app/bdsh/cmds/modules/ls/ls.h
===================================================================
--- uspace/app/bdsh/cmds/modules/ls/ls.h	(revision c7afdf7aeb7a9b267482b637a8124172e3357f16)
+++ uspace/app/bdsh/cmds/modules/ls/ls.h	(revision f4f4b95e62a33cdf2a50bf7841b07ccb8ade8dff)
@@ -27,5 +27,5 @@
 	bool exact_size;
 
-	void (*printer)(struct dir_elem_t *);
+	bool (*printer)(struct dir_elem_t *);
 } ls_job_t;
 
