summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--fish/Makefile.am1
-rw-r--r--fish/echo.c39
-rw-r--r--fish/fish.c9
-rw-r--r--fish/fish.h3
4 files changed, 52 insertions, 0 deletions
diff --git a/fish/Makefile.am b/fish/Makefile.am
index 016e9b38..b3782eca 100644
--- a/fish/Makefile.am
+++ b/fish/Makefile.am
@@ -21,6 +21,7 @@ guestfish_SOURCES = \
alloc.c \
cmds.c \
completion.c \
+ echo.c \
edit.c \
fish.c \
fish.h
diff --git a/fish/echo.c b/fish/echo.c
new file mode 100644
index 00000000..b4b5cf1d
--- /dev/null
+++ b/fish/echo.c
@@ -0,0 +1,39 @@
+/* guestfish - the filesystem interactive shell
+ * Copyright (C) 2009 Red Hat Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#include <config.h>
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "fish.h"
+
+int
+do_echo (const char *cmd, int argc, char *argv[])
+{
+ int i;
+
+ for (i = 0; i < argc; ++i) {
+ if (i > 0) printf (" ");
+ printf ("%s", argv[i]);
+ }
+ printf ("\n");
+
+ return 0;
+}
diff --git a/fish/fish.c b/fish/fish.c
index 894e351d..fcafb5ca 100644
--- a/fish/fish.c
+++ b/fish/fish.c
@@ -523,6 +523,8 @@ issue_command (const char *cmd, char *argv[])
else if (strcasecmp (cmd, "alloc") == 0 ||
strcasecmp (cmd, "allocate") == 0)
return do_alloc (cmd, argc, argv);
+ else if (strcasecmp (cmd, "echo") == 0)
+ return do_echo (cmd, argc, argv);
else if (strcasecmp (cmd, "edit") == 0 ||
strcasecmp (cmd, "vi") == 0 ||
strcasecmp (cmd, "emacs") == 0)
@@ -543,6 +545,8 @@ list_builtin_commands (void)
printf ("%-20s %s\n",
"alloc", "allocate an image");
printf ("%-20s %s\n",
+ "echo", "display a line of text");
+ printf ("%-20s %s\n",
"edit", "edit a file in the image");
/* actions are printed after this (see list_commands) */
@@ -570,6 +574,11 @@ display_builtin_command (const char *cmd)
" <nn>M or <nn>MB number of megabytes\n"
" <nn>G or <nn>GB number of gigabytes\n"
" <nn>sects number of 512 byte sectors\n");
+ else if (strcasecmp (cmd, "echo") == 0)
+ printf ("echo - display a line of text\n"
+ " echo [<params> ...]\n"
+ "\n"
+ " This echos the parameters to the terminal.\n");
else if (strcasecmp (cmd, "edit") == 0 ||
strcasecmp (cmd, "vi") == 0 ||
strcasecmp (cmd, "emacs") == 0)
diff --git a/fish/fish.h b/fish/fish.h
index c4450a79..40f19901 100644
--- a/fish/fish.h
+++ b/fish/fish.h
@@ -47,6 +47,9 @@ extern char **do_completion (const char *text, int start, int end);
/* in alloc.c */
extern int do_alloc (const char *cmd, int argc, char *argv[]);
+/* in echo.c */
+extern int do_echo (const char *cmd, int argc, char *argv[]);
+
/* in edit.c */
extern int do_edit (const char *cmd, int argc, char *argv[]);