From 4f6670e5af2e3eea457d48d8e4888b712fdcf5ad Mon Sep 17 00:00:00 2001 From: Peter Zotov Date: Sat, 4 Dec 2010 05:17:56 +0300 Subject: [PATCH] Fix echo shell command to print all arguments. --- shell.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/shell.c b/shell.c index bbe24e6..524de3a 100644 --- a/shell.c +++ b/shell.c @@ -319,7 +319,16 @@ static int builtin_echo(int argc, char *argv[]) { return -1; } - puts(argv[1]); + for(int i = 1; i < argc; i++) { + printf("%s", argv[i]); + + if(i < argc - 1) { + printf(" "); + + } else { + printf("\n"); + } + } return 0; }