Index: uspace/app/bdsh/input.c
===================================================================
--- uspace/app/bdsh/input.c	(revision 82570ff5faaff23ad6167454f598c240d2c94549)
+++ uspace/app/bdsh/input.c	(revision 3d36920ec9022ed00fbf5e2d54ce1768d27de581)
@@ -251,5 +251,5 @@
 	}
 
-	for (unsigned p = 0; p < pipe_count; p++) {
+	for (unsigned p = 0; p <= pipe_count; p++) {
 		/* Convert tokens of the command to string array */
 		unsigned int cmd_pos = 0;
@@ -259,5 +259,5 @@
 			}
 		}
-		cmd[cmd_pos++] = NULL;
+		cmd[cmd_pos] = NULL;
 
 		if (cmd[0] == NULL) {
@@ -282,8 +282,9 @@
 		}
 
-
-		if (p < pipe_count - 1) {
+		if (p < pipe_count) {
 			new_iostate.stdout = to;
-		} else {
+		}
+		if (p && p == pipe_count) {
+			fseek(to, 0, SEEK_SET);
 			new_iostate.stdin = to;
 		}
@@ -302,45 +303,4 @@
 		cmd_token_start = cmd_token_end + 1;
 		cmd_token_end = (p < pipe_count - 1) ? pipe_pos[p + 1] : tokens_length;
-	}
-
-	unsigned int cmd_pos = 0;
-	for (i = cmd_token_start; i < cmd_token_end; i++) {
-		if (tokens[i].type != TOKTYPE_SPACE) {
-			cmd[cmd_pos++] = tokens[i].text;
-		}
-	}
-	cmd[cmd_pos++] = NULL;
-
-	if (cmd[0] == NULL) {
-		printf("Command not found.\n");
-		rc = ENOTSUP;
-		goto finit;
-	}
-
-	alias_t *data = NULL;
-	rc = find_alias(cmd, alias_hups, &data);
-	if (rc != EOK) {
-		goto finit;
-	}
-
-	if (data != NULL) {
-		rc = replace_alias(tokens, cmd_token_start, tokens_length, data, cmd, &usr->line);
-		if (rc == EOK) {
-			/* reprocess input after string replace */
-			rc = process_input_nohup(usr, alias_hups, count_executed_hups + 1);
-		}
-		goto finit;
-	}
-
-	if (pipe_count) {
-		fseek(to, 0, SEEK_SET);
-		new_iostate.stdin = to;
-	}
-
-
-	if (run_command(cmd, usr, &new_iostate) == 0) {
-		rc = EOK;
-	} else {
-		rc = EINVAL;
 	}
 
