/* guestfish - the filesystem interactive shell
- * Copyright (C) 2009 Red Hat Inc.
+ * 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
r = do_lcd (cmd, argc, argv);
else if (strcasecmp (cmd, "glob") == 0)
r = do_glob (cmd, argc, argv);
+ else if (strcasecmp (cmd, "more") == 0 ||
+ strcasecmp (cmd, "less") == 0)
+ r = do_more (cmd, argc, argv);
+ else if (strcasecmp (cmd, "time") == 0)
+ r = do_time (cmd, argc, argv);
else
r = run_action (cmd, argc, argv);
"lcd", _("local change directory"));
printf ("%-20s %s\n",
"glob", _("expand wildcards in command"));
+ printf ("%-20s %s\n",
+ "time", _("measure time taken to run command"));
/* actions are printed after this (see list_commands) */
}
" Glob runs <command> with wildcards expanded in any\n"
" command args. Note that the command is run repeatedly\n"
" once for each expanded argument.\n"));
+ else if (strcasecmp (cmd, "more") == 0 ||
+ strcasecmp (cmd, "less") == 0)
+ printf (_("more - view a file in the pager\n"
+ " more <filename>\n"
+ "\n"
+ " This is used to view a file in the pager.\n"
+ "\n"
+ " It is the equivalent of (and is implemented by)\n"
+ " running \"cat\" and using the pager.\n"
+ "\n"
+ " Normally it uses $PAGER, but if you use the alias\n"
+ " \"less\" then it always uses \"less\".\n"
+ "\n"
+ " NOTE: This will not work reliably for large files\n"
+ " (> 2 MB) or binary files containing \\0 bytes.\n"));
else if (strcasecmp (cmd, "help") == 0)
printf (_("help - display a list of commands or help on a command\n"
" help cmd\n"
strcasecmp (cmd, "q") == 0)
printf (_("quit - quit guestfish\n"
" quit\n"));
+ else if (strcasecmp (cmd, "time") == 0)
+ printf (_("time - measure time taken to run command\n"
+ " time <command> [<args> ...]\n"
+ "\n"
+ " This runs <command> as usual, and prints the elapsed\n"
+ " time afterwards.\n"));
else
fprintf (stderr, _("%s: command not known, use -h to list all commands\n"),
cmd);
nr_history_lines++;
#endif
}
+
+int
+xwrite (int fd, const void *buf, size_t len)
+{
+ int r;
+
+ while (len > 0) {
+ r = write (fd, buf, len);
+ if (r == -1) {
+ perror ("write");
+ return -1;
+ }
+ buf += r;
+ len -= r;
+ }
+
+ return 0;
+}