mirror of
https://github.com/libguestfs/libguestfs.git
synced 2026-03-21 22:53:37 +00:00
Added guestfish 'echo' command.
This commit is contained in:
@@ -21,6 +21,7 @@ guestfish_SOURCES = \
|
||||
alloc.c \
|
||||
cmds.c \
|
||||
completion.c \
|
||||
echo.c \
|
||||
edit.c \
|
||||
fish.c \
|
||||
fish.h
|
||||
|
||||
39
fish/echo.c
Normal file
39
fish/echo.c
Normal file
@@ -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;
|
||||
}
|
||||
@@ -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)
|
||||
@@ -542,6 +544,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");
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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[]);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user