summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorIan Moffett <ian@osmora.org>2025-10-16 00:06:24 -0400
committerIan Moffett <ian@osmora.org>2025-10-16 00:06:24 -0400
commit167bb8ba90c7d94b95c1d7df04005f201fb67032 (patch)
tree24c15d1dc7ad629324574b5afbc83f2f1b4b9ac1 /src
parent939c4c7d6c9bd9614626990a1644dec63ea71203 (diff)
cmd: Add new 'echo' command
Signed-off-by: Ian Moffett <ian@osmora.org>
Diffstat (limited to 'src')
-rw-r--r--src/cmd/Makefile3
-rw-r--r--src/cmd/echo/Makefile18
-rw-r--r--src/cmd/echo/echo.c42
3 files changed, 63 insertions, 0 deletions
diff --git a/src/cmd/Makefile b/src/cmd/Makefile
index e4ff13e..1263be8 100644
--- a/src/cmd/Makefile
+++ b/src/cmd/Makefile
@@ -18,6 +18,8 @@ all:
LIBC_DIR=$(shell pwd)/../$(LIBC_DIR)
cd login/; make LDSCRIPT=$(LDSCRIPT) CC=$(CC) AS=$(AS) LD=$(LD) SYSROOT=$(SYSROOT) \
LIBC_DIR=$(shell pwd)/../$(LIBC_DIR)
+ cd echo/; make LDSCRIPT=$(LDSCRIPT) CC=$(CC) AS=$(AS) LD=$(LD) SYSROOT=$(SYSROOT) \
+ LIBC_DIR=$(shell pwd)/../$(LIBC_DIR)
.PHONY: clean
clean:
@@ -27,3 +29,4 @@ clean:
cd fetch/; make clean
cd lsdisk/; make clean
cd login/; make clean
+ cd echo/; make clean
diff --git a/src/cmd/echo/Makefile b/src/cmd/echo/Makefile
new file mode 100644
index 0000000..40b3d93
--- /dev/null
+++ b/src/cmd/echo/Makefile
@@ -0,0 +1,18 @@
+include ../../data/build/user.mk
+
+CFILES = $(shell find . -name "*.c")
+CFILES = $(shell find . -name "*.c")
+CFLAGS = -L$(LIBC_DIR) -lc $(INTERNAL_CFLAGS) \
+ -L../../lib/libwidget -lwidget -L../../lib/libc/ -lc \
+ -I../../lib/libwidget/include/
+OBJECTS = $(CFILES:%.c=%.o)
+
+$(SYSROOT)/usr/bin/echo: $(OBJECTS)
+ $(LD) $(OBJECTS) -o $@ $(CFLAGS)
+
+%.o: %.c
+ $(CC) $(INTERNAL_CFLAGS) -c $(CFLAGS) $< -o $@
+
+.PHONY: clean
+clean:
+ rm -f *.o *.d
diff --git a/src/cmd/echo/echo.c b/src/cmd/echo/echo.c
new file mode 100644
index 0000000..a03ebd1
--- /dev/null
+++ b/src/cmd/echo/echo.c
@@ -0,0 +1,42 @@
+/*
+ * Copyright (c) 2025 Ian Marco Moffett and L5 engineers
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the project nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <stdio.h>
+#include <stdarg.h>
+
+int
+main(void)
+{
+ for (int i = 1; i < __argc; ++i) {
+ printf("%s ", __argv[i]);
+ }
+
+ printf("\n");
+ return 0;
+}