diff options
author | Richard Jones <rjones@trick.home.annexia.org> | 2009-06-22 08:20:42 +0100 |
---|---|---|
committer | Richard Jones <rjones@trick.home.annexia.org> | 2009-06-22 08:20:42 +0100 |
commit | ad8a256f54a6cb99f89bb444c8597a152a793dce (patch) | |
tree | f82b1ef05fe745c9cb2ec93275b9d0909f1a882e /fish | |
parent | 05c34c1c1479bb07b31cfbf912743a8cf014a636 (diff) | |
download | libguestfs-ad8a256f54a6cb99f89bb444c8597a152a793dce.tar.gz libguestfs-ad8a256f54a6cb99f89bb444c8597a152a793dce.tar.xz libguestfs-ad8a256f54a6cb99f89bb444c8597a152a793dce.zip |
Generated code for 'glob-expand'.
Diffstat (limited to 'fish')
-rw-r--r-- | fish/cmds.c | 24 | ||||
-rw-r--r-- | fish/completion.c | 1 |
2 files changed, 25 insertions, 0 deletions
diff --git a/fish/cmds.c b/fish/cmds.c index fe1ef92e..8c35eea2 100644 --- a/fish/cmds.c +++ b/fish/cmds.c @@ -84,6 +84,7 @@ void list_commands (void) printf ("%-20s %s\n", "get-qemu", "get the qemu binary"); printf ("%-20s %s\n", "get-state", "get the current state"); printf ("%-20s %s\n", "get-verbose", "get verbose mode"); + printf ("%-20s %s\n", "glob-expand", "expand a wildcard path"); printf ("%-20s %s\n", "grub-install", "install GRUB"); printf ("%-20s %s\n", "hexdump", "dump a file in hexadecimal"); printf ("%-20s %s\n", "is-busy", "is busy processing a command"); @@ -568,6 +569,9 @@ void display_command (const char *cmd) if (strcasecmp (cmd, "sh_lines") == 0 || strcasecmp (cmd, "sh-lines") == 0) pod2text ("sh-lines - run a command via the shell returning lines", " sh-lines <command>\n\nThis is the same as C<sh>, but splits the result\ninto a list of lines.\n\nSee also: C<command_lines>"); else + if (strcasecmp (cmd, "glob_expand") == 0 || strcasecmp (cmd, "glob-expand") == 0) + pod2text ("glob-expand - expand a wildcard path", " glob-expand <pattern>\n\nThis command searches for all the pathnames matching\nC<pattern> according to the wildcard expansion rules\nused by the shell.\n\nIf no paths match, then this returns an empty list\n(note: not an error).\n\nIt is just a wrapper around the C L<glob(3)> function\nwith flags C<GLOB_MARK|GLOB_BRACE>.\nSee that manual page for more details."); + else display_builtin_command (cmd); } @@ -2780,6 +2784,23 @@ static int run_sh_lines (const char *cmd, int argc, char *argv[]) return 0; } +static int run_glob_expand (const char *cmd, int argc, char *argv[]) +{ + char **r; + const char *pattern; + if (argc != 1) { + fprintf (stderr, "%s should have 1 parameter(s)\n", cmd); + fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd); + return -1; + } + pattern = argv[0]; + r = guestfs_glob_expand (g, pattern); + if (r == NULL) return -1; + print_strings (r); + free_strings (r); + return 0; +} + int run_action (const char *cmd, int argc, char *argv[]) { if (strcasecmp (cmd, "launch") == 0 || strcasecmp (cmd, "run") == 0) @@ -3181,6 +3202,9 @@ int run_action (const char *cmd, int argc, char *argv[]) if (strcasecmp (cmd, "sh_lines") == 0 || strcasecmp (cmd, "sh-lines") == 0) return run_sh_lines (cmd, argc, argv); else + if (strcasecmp (cmd, "glob_expand") == 0 || strcasecmp (cmd, "glob-expand") == 0) + return run_glob_expand (cmd, argc, argv); + else { fprintf (stderr, "%s: unknown command\n", cmd); return -1; diff --git a/fish/completion.c b/fish/completion.c index 4ac0fad9..e8d8cea5 100644 --- a/fish/completion.c +++ b/fish/completion.c @@ -179,6 +179,7 @@ static const char *const commands[] = { "ntfs-3g-probe", "sh", "sh-lines", + "glob-expand", NULL }; |