From 0006fae5d6885806d0f7231ae317d6e639af84ce Mon Sep 17 00:00:00 2001 From: "Jordan K. Hubbard" Date: Wed, 26 Jun 1996 09:09:30 +0000 Subject: Allow argv[0] to be a command also. --- usr.sbin/sade/dispatch.c | 8 ++++++-- usr.sbin/sade/main.c | 24 +++++++++++++++++------- usr.sbin/sade/menus.c | 4 ++-- usr.sbin/sysinstall/dispatch.c | 8 ++++++-- usr.sbin/sysinstall/main.c | 24 +++++++++++++++++------- usr.sbin/sysinstall/menus.c | 4 ++-- 6 files changed, 50 insertions(+), 22 deletions(-) (limited to 'usr.sbin') diff --git a/usr.sbin/sade/dispatch.c b/usr.sbin/sade/dispatch.c index 8a51adea9a2d..ebf0d4efc914 100644 --- a/usr.sbin/sade/dispatch.c +++ b/usr.sbin/sade/dispatch.c @@ -4,7 +4,7 @@ * This is probably the last program in the `sysinstall' line - the next * generation being essentially a complete rewrite. * - * $Id: dispatch.c,v 1.1 1996/05/16 11:47:27 jkh Exp $ + * $Id: dispatch.c,v 1.2 1996/06/08 09:08:38 jkh Exp $ * * Copyright (c) 1995 * Jordan Hubbard. All rights reserved. @@ -107,12 +107,16 @@ int dispatchCommand(char *str) { int i; + char *cp; if (!str || !*str) { msgConfirm("Null or zero-length string passed to dispatchCommand"); return DITEM_FAILURE; } - else if (index(str, '=')) { + /* A command might be a pathname if it's encoded in argv[0], as we also support */ + if ((cp = index(str, '/')) != NULL) + str = cp + 1; + if (index(str, '=')) { variable_set(str); return DITEM_SUCCESS; } diff --git a/usr.sbin/sade/main.c b/usr.sbin/sade/main.c index c7cdffe7436a..c74a8678ee7b 100644 --- a/usr.sbin/sade/main.c +++ b/usr.sbin/sade/main.c @@ -4,7 +4,7 @@ * This is probably the last attempt in the `sysinstall' line, the next * generation being slated for what's essentially a complete rewrite. * - * $Id: main.c,v 1.20 1996/05/28 18:30:30 jkh Exp $ + * $Id: main.c,v 1.21 1996/06/08 07:02:20 jkh Exp $ * * Copyright (c) 1995 * Jordan Hubbard. All rights reserved. @@ -42,7 +42,10 @@ static void screech(int sig) { fprintf(stderr, "\007Fatal signal %d caught! I'm dead..\n", sig); - pause(); + if (RunningAsInit) + pause(); + else + exit(1); } int @@ -89,14 +92,21 @@ main(int argc, char **argv) if (!mediaDevice->init(mediaDevice)) mediaDevice = NULL; } - if (argc > 1 && !RunningAsInit) { - int i; - for (i = 1; i < argc; i++) { + /* First, see if we have any arguments to process (and argv[0] counts if it's not "sysinstall") */ + if (!RunningAsInit) { + int i, start_arg; + + if (!strstr(argv[0], "sysinstall")) + start_arg = 0; + else + start_arg = 1; + for (i = start_arg; i < argc; i++) { if (DITEM_STATUS(dispatchCommand(argv[i])) != DITEM_SUCCESS) systemShutdown(1); - } - systemShutdown(0); + } + if (argc > start_arg) + systemShutdown(0); } /* Begin user dialog at outer menu */ diff --git a/usr.sbin/sade/menus.c b/usr.sbin/sade/menus.c index 2377af405b34..3d5a0ff9e174 100644 --- a/usr.sbin/sade/menus.c +++ b/usr.sbin/sade/menus.c @@ -4,7 +4,7 @@ * This is probably the last program in the `sysinstall' line - the next * generation being essentially a complete rewrite. * - * $Id: menus.c,v 1.70 1996/06/17 19:31:34 jkh Exp $ + * $Id: menus.c,v 1.71 1996/06/17 19:33:27 jkh Exp $ * * Copyright (c) 1995 * Jordan Hubbard. All rights reserved. @@ -240,7 +240,7 @@ DMenu MenuIndex = { { "Install, Express", "An express system installation.", NULL, installExpress }, { "Install, Custom", "The custom installation menu", NULL, dmenuSubmenu, NULL, &MenuInstallCustom }, { "Label", "The disk Label editor", NULL, diskLabelEditor }, - { "Media, All", "Top level media selection menu.", NULL, dmenuSubmenu, NULL, &MenuMedia }, + { "Media", "Top level media selection menu.", NULL, dmenuSubmenu, NULL, &MenuMedia }, { "Media, Tape", "Select tape installation media.", NULL, mediaSetTape }, { "Media, NFS", "Select NFS installation media.", NULL, mediaSetNFS }, { "Media, Floppy", "Select floppy installation media.", NULL, mediaSetFloppy }, diff --git a/usr.sbin/sysinstall/dispatch.c b/usr.sbin/sysinstall/dispatch.c index 8a51adea9a2d..ebf0d4efc914 100644 --- a/usr.sbin/sysinstall/dispatch.c +++ b/usr.sbin/sysinstall/dispatch.c @@ -4,7 +4,7 @@ * This is probably the last program in the `sysinstall' line - the next * generation being essentially a complete rewrite. * - * $Id: dispatch.c,v 1.1 1996/05/16 11:47:27 jkh Exp $ + * $Id: dispatch.c,v 1.2 1996/06/08 09:08:38 jkh Exp $ * * Copyright (c) 1995 * Jordan Hubbard. All rights reserved. @@ -107,12 +107,16 @@ int dispatchCommand(char *str) { int i; + char *cp; if (!str || !*str) { msgConfirm("Null or zero-length string passed to dispatchCommand"); return DITEM_FAILURE; } - else if (index(str, '=')) { + /* A command might be a pathname if it's encoded in argv[0], as we also support */ + if ((cp = index(str, '/')) != NULL) + str = cp + 1; + if (index(str, '=')) { variable_set(str); return DITEM_SUCCESS; } diff --git a/usr.sbin/sysinstall/main.c b/usr.sbin/sysinstall/main.c index c7cdffe7436a..c74a8678ee7b 100644 --- a/usr.sbin/sysinstall/main.c +++ b/usr.sbin/sysinstall/main.c @@ -4,7 +4,7 @@ * This is probably the last attempt in the `sysinstall' line, the next * generation being slated for what's essentially a complete rewrite. * - * $Id: main.c,v 1.20 1996/05/28 18:30:30 jkh Exp $ + * $Id: main.c,v 1.21 1996/06/08 07:02:20 jkh Exp $ * * Copyright (c) 1995 * Jordan Hubbard. All rights reserved. @@ -42,7 +42,10 @@ static void screech(int sig) { fprintf(stderr, "\007Fatal signal %d caught! I'm dead..\n", sig); - pause(); + if (RunningAsInit) + pause(); + else + exit(1); } int @@ -89,14 +92,21 @@ main(int argc, char **argv) if (!mediaDevice->init(mediaDevice)) mediaDevice = NULL; } - if (argc > 1 && !RunningAsInit) { - int i; - for (i = 1; i < argc; i++) { + /* First, see if we have any arguments to process (and argv[0] counts if it's not "sysinstall") */ + if (!RunningAsInit) { + int i, start_arg; + + if (!strstr(argv[0], "sysinstall")) + start_arg = 0; + else + start_arg = 1; + for (i = start_arg; i < argc; i++) { if (DITEM_STATUS(dispatchCommand(argv[i])) != DITEM_SUCCESS) systemShutdown(1); - } - systemShutdown(0); + } + if (argc > start_arg) + systemShutdown(0); } /* Begin user dialog at outer menu */ diff --git a/usr.sbin/sysinstall/menus.c b/usr.sbin/sysinstall/menus.c index 2377af405b34..3d5a0ff9e174 100644 --- a/usr.sbin/sysinstall/menus.c +++ b/usr.sbin/sysinstall/menus.c @@ -4,7 +4,7 @@ * This is probably the last program in the `sysinstall' line - the next * generation being essentially a complete rewrite. * - * $Id: menus.c,v 1.70 1996/06/17 19:31:34 jkh Exp $ + * $Id: menus.c,v 1.71 1996/06/17 19:33:27 jkh Exp $ * * Copyright (c) 1995 * Jordan Hubbard. All rights reserved. @@ -240,7 +240,7 @@ DMenu MenuIndex = { { "Install, Express", "An express system installation.", NULL, installExpress }, { "Install, Custom", "The custom installation menu", NULL, dmenuSubmenu, NULL, &MenuInstallCustom }, { "Label", "The disk Label editor", NULL, diskLabelEditor }, - { "Media, All", "Top level media selection menu.", NULL, dmenuSubmenu, NULL, &MenuMedia }, + { "Media", "Top level media selection menu.", NULL, dmenuSubmenu, NULL, &MenuMedia }, { "Media, Tape", "Select tape installation media.", NULL, mediaSetTape }, { "Media, NFS", "Select NFS installation media.", NULL, mediaSetNFS }, { "Media, Floppy", "Select floppy installation media.", NULL, mediaSetFloppy }, -- cgit v1.2.3