summaryrefslogtreecommitdiffstats
path: root/sys/boot/common/commands.c
diff options
context:
space:
mode:
authormsmith <msmith@FreeBSD.org>1998-10-07 02:38:26 +0000
committermsmith <msmith@FreeBSD.org>1998-10-07 02:38:26 +0000
commit387d0e8c2b336bf34a8b434f0f090fd31e4e3d7f (patch)
treef649378e8cb57ba1e3a2d3e85e6ba1f68a44bd51 /sys/boot/common/commands.c
parent436333e172727c23d47b79a4e1e45dbc916b5dec (diff)
downloadFreeBSD-src-387d0e8c2b336bf34a8b434f0f090fd31e4e3d7f.zip
FreeBSD-src-387d0e8c2b336bf34a8b434f0f090fd31e4e3d7f.tar.gz
- VERBOSE_LS is obsolete, as the heap is much better behaved now.
- Don't whine about nodes we can't stat(); these are usually symlinks that lead out of the filesystem. - Autoboot is now controlled by $autoboot_delay, which is a value in seconds or NO to disable autoboot. - Don't autoboot at the end of boot.conf if we have already tried. - Add a 'read' command to complement 'echo'. Both are still hidden. - Improve the 'source' command/function so that it is possible to source scripts off removable media. The entire script is read and saved before beginning execution. Script lines beginning with '@' will not be echoed when being executed. Script execution will normally terminate at the first error, however if the script line begins with '-' this behaviour is overriden for that command.
Diffstat (limited to 'sys/boot/common/commands.c')
-rw-r--r--sys/boot/common/commands.c63
1 files changed, 61 insertions, 2 deletions
diff --git a/sys/boot/common/commands.c b/sys/boot/common/commands.c
index e7b6725..b0d0518 100644
--- a/sys/boot/common/commands.c
+++ b/sys/boot/common/commands.c
@@ -23,7 +23,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: commands.c,v 1.2 1998/09/03 02:10:07 msmith Exp $
+ * $Id: commands.c,v 1.3 1998/09/18 02:01:38 msmith Exp $
*/
#include <stand.h>
@@ -43,7 +43,7 @@ command_help(int argc, char *argv[])
char helppath[80]; /* XXX buffer size? */
/* page the help text from our load path */
- sprintf(helppath, "%s/boot.help", getenv("loaddev"));
+ sprintf(helppath, "%s/boot/boot.help", getenv("loaddev"));
printf("%s\n", helppath);
if (pager_file(helppath) == -1)
printf("Verbose help not available, use '?' to list commands\n");
@@ -177,3 +177,62 @@ command_echo(int argc, char *argv[])
return(CMD_OK);
}
+/*
+ * A passable emulation of the sh(1) command of the same name.
+ */
+
+COMMAND_SET(read, "read", NULL, command_read);
+
+static int
+command_read(int argc, char *argv[])
+{
+ char *prompt;
+ int timeout;
+ time_t when;
+ char *cp;
+ char *name;
+ char buf[256]; /* XXX size? */
+ int c;
+
+ timeout = -1;
+ prompt = NULL;
+ optind = 1;
+ while ((c = getopt(argc, argv, "p:t:")) != -1) {
+ switch(c) {
+
+ case 'p':
+ prompt = optarg;
+ break;
+ case 't':
+ timeout = strtol(optarg, &cp, 0);
+ if (cp == optarg) {
+ sprintf(command_errbuf, "bad timeout '%s'", optarg);
+ return(CMD_ERROR);
+ }
+ break;
+ default:
+ return(CMD_OK);
+ }
+ }
+
+ argv += (optind);
+ argc -= (optind);
+ name = (argc > 0) ? argv[0]: NULL;
+
+ if (prompt != NULL)
+ printf(prompt);
+ if (timeout >= 0) {
+ when = time(NULL) + timeout;
+ while (!ischar())
+ if (time(NULL) >= when)
+ return(CMD_OK); /* is timeout an error? */
+ }
+
+ ngets(buf, sizeof(buf));
+
+ printf("read name '%s' value '%s'\n", name, buf);
+
+ if (name != NULL)
+ setenv(name, buf, 1);
+ return(CMD_OK);
+}
OpenPOWER on IntegriCloud