Add internal command echo

This commit is contained in:
Artur Tamborski 2018-12-17 01:59:10 +01:00
parent 858eb84444
commit ace246133e
3 changed files with 15 additions and 1 deletions

View File

@ -12,7 +12,7 @@ CC = gcc
LD = gcc LD = gcc
LDFLAGS = -lm -lpthread 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) SRCTREE = $(shell find $(SRCDIR) -type d)
INCS = $(shell find $(INCDIR) -type f -name '*$(INCEXT)') INCS = $(shell find $(INCDIR) -type f -name '*$(INCEXT)')

View File

@ -32,6 +32,7 @@ struct icmd
} g_icmds[] = } g_icmds[] =
{ {
ICMD(help), ICMD(help),
ICMD(echo),
ICMD(exit), ICMD(exit),
ICMD(cls), ICMD(cls),
ICMD(cd), 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 int
icmd_exit(int argc, char **argv) icmd_exit(int argc, char **argv)
{ {

View File

@ -8,6 +8,7 @@ int call_icmd(int argc, char **argv);
/* internal commands */ /* internal commands */
int icmd_help(int argc, char **argv); int icmd_help(int argc, char **argv);
int icmd_echo(int argc, char **argv);
int icmd_exit(int argc, char **argv); int icmd_exit(int argc, char **argv);
int icmd_cls(int argc, char **argv); int icmd_cls(int argc, char **argv);
int icmd_cd(int argc, char **argv); int icmd_cd(int argc, char **argv);