commit - 0fa6b08d3c709fc60f694dc892e4ac47ecce9180
commit + 6eaf41b8f48d8bf640fc5fee0283fecad5784b7b
blob - d1fd8608b297e7f4f9b9462f1badefa3bf6de53c
blob + 370a8a0c5e2a790ac3e60edeaf6970ddefe9177f
--- commands.c
+++ commands.c
static int
int_shell(char *ifname, int ifs, int argc, char **argv)
{
- shell(argc, argv);
- return 0; /* do not leave interface context */
+ if (argc >1)
+ {
+ shell(argc, argv);
+ return 0; /* do not leave interface context after execution */
+ }
+ else
+ return 1; /* this is to allow for pasting configs with "!" separators */
}
static int
setenvhelp[] = "Set an environment variable",
unsetenvhelp[] ="Delete an environment variable",
saveenvhelp[] = "Save environment variables set by setenv to ~/.nshenv",
- shellhelp[] = "Invoke a subshell",
+ shellhelp[] = "Invoke a subshell or run an executable",
savehelp[] = "Save the current configuration",
nreboothelp[] = "Reboot the system",
halthelp[] = "Halt the system",
sigint = signal(SIGINT, SIG_IGN);
sigquit = signal(SIGQUIT, SIG_IGN);
sigchld = signal(SIGCHLD, SIG_DFL);
-
- switch(child = fork()) {
+ if (argc <= 1) /* only fork if you have a command or shell to execute*/
+ return 1;
+ else {
+ switch(child = fork()) {
case -1:
printf("%% fork failed: %s\n", strerror(errno));
break;
*/
char *shellp;
char *shellname = shellp = "/bin/sh";
-
- if (argc > 1)
- execl(shellp, shellname, "-c", &saveline[1],
- (char *)NULL);
- else
- execl(shellp, shellname, (char *)NULL);
+ execl(shellp, shellname, "-c", &saveline[1],
+ (char *)NULL);
printf("%% execl '%s' failed: %s\n", shellp,
- strerror(errno));
+ strerror(errno));
_exit(0);
}
break;
signal(SIGALRM, sigalarm);
wait(0); /* Wait for shell to complete */
break;
- }
+ }
signal(SIGINT, sigint);
signal(SIGQUIT, sigquit);
child = -1;
return 1;
+ }
+
}
/*
blob - 88dd2ed47b47ccea3b21853c987e0b10296e0789
blob + 8ecda1e96860d87bb8d388707477c4ee0e230320
--- nsh.8
+++ nsh.8
verbose Set verbose diagnostics
editing Set command line editing
who Display system users
- ! Invoke a subshell
+ ! Invoke a subshell or run an executable
? Print help information
quit Close current connection
nsh(p)/
who Display system users
verbose Set verbose diagnostics
editing Set command line editing
- ! Invoke a subshell
+ ! Invoke a subshell or run an executable
? Options
manual Display the NSH manual
exit Leave bridge config mode and return to global config mode
.Tg sh
.Tg csh
.Ic nsh(p)/!
-.Op Cm shell-command
-.Ar argument-1
+.Ar Cm shell-command
+.Op argument-1
.Op Ar argument-n
.Pp
-Invoke a shell or run an entered shell-command with arguments if required.
+Invoke a shell or run an entered executable with arguments if required.
(requires privileged mode).
The active users login shell is the shell that is invoked by this feature.
-This feature disabled to enhance security.
+This feature can be disabled to restrict users from starting a different
+shell or executable from
+.Nm
+.
+If ! is entered without arguments in privilaged mode or global config mode,
+no operation will be carried out and the user will be returned to the same
+.Nm
+command prompt.
+If ! is entered without arguments in interface or bridge config mode the,
+no operation will be carried out but the user will be returned to the global
+configuration mode.
+This is to facilitate users interactively copying and pasting
+.Nm
+configurations between devices which would contain the "!" spacing character.
.Pp
E.g. list files in /root
.Bd -literal -offset indent
helloworld.c
helloworld2.c
-nsh(p)/!
+nsh(p)/!ksh
-OpenBSDshell#
+kshprompt#
.Ed
.Pp
.Tg ip
who Display system users
verbose Set verbose diagnostics
editing Set command line editing
- ! Invoke a subshell
+ ! Invoke a subshell or run an executable
? Options
manual Display the NSH manual
exit Leave interface config mode and return to global config mode