From ace246133e4e8f78af79a5df7612a1c0790e94f6 Mon Sep 17 00:00:00 2001 From: Artur Tamborski Date: Mon, 17 Dec 2018 01:59:10 +0100 Subject: [PATCH] Add internal command echo --- makefile | 2 +- src/icmd.c | 13 +++++++++++++ src/icmd.h | 1 + 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/makefile b/makefile index 0340e78..6e87810 100644 --- a/makefile +++ b/makefile @@ -12,7 +12,7 @@ CC = gcc LD = gcc LDFLAGS = -lm -lpthread -CCFLAGS = -std=gnu99 -g -ggdb -Og -Wall -Wextra -pedantic +CCFLAGS = -std=gnu99 -g -ggdb -Og -Wall -Wextra -pedantic -Wno-unused-parameter SRCTREE = $(shell find $(SRCDIR) -type d) INCS = $(shell find $(INCDIR) -type f -name '*$(INCEXT)') diff --git a/src/icmd.c b/src/icmd.c index ef9a603..8683c09 100644 --- a/src/icmd.c +++ b/src/icmd.c @@ -32,6 +32,7 @@ struct icmd } g_icmds[] = { ICMD(help), + ICMD(echo), ICMD(exit), ICMD(cls), ICMD(cd), @@ -98,6 +99,18 @@ icmd_help(int argc, char **argv) } +int +icmd_echo(int argc, char **argv) +{ + int i; + + for (i = 1; i < argc; i++) + printf("%s%c", argv[i], (argc - i != 1) ? ' ' : '\n'); + + return 0; +} + + int icmd_exit(int argc, char **argv) { diff --git a/src/icmd.h b/src/icmd.h index 1cfe9d1..8e2f609 100644 --- a/src/icmd.h +++ b/src/icmd.h @@ -8,6 +8,7 @@ int call_icmd(int argc, char **argv); /* internal commands */ int icmd_help(int argc, char **argv); +int icmd_echo(int argc, char **argv); int icmd_exit(int argc, char **argv); int icmd_cls(int argc, char **argv); int icmd_cd(int argc, char **argv);