yellowman / nsh

OpenBSD networking configuration shell
http://www.nmedia.net/nsh/
Other
174 stars 27 forks source link

add 'show environment', 'setenv', and 'unsetenv' commands #139

Closed stspdotname closed 1 year ago

stspdotname commented 1 year ago

Being able to manage environment variables from within nsh will be useful, especially if nsh is used as a login shell because nsh's environment is visible to other commands run by nsh.

Setting variables can now affect the behaviour of nsh itself. For example, it is possible to set NSH_MANUAL_PAGE from within a running nsh session and the new value will immediately be used by the 'manual' command. This particular variable is only useful to nsh developers themselves but the same mechanism could be used for user-facing variables in the future.

If 'show environment' is run without further arguments all variables will be displayed. Otherwise the value of the specified variable will be displayed if the variable exists.

All commands support tab-completion for names which already exist in the environment. The 'setenv' commands appends "=" if the name being completed does not yet exist in the environment.

stspdotname commented 1 year ago

By the way, an 'appendenv' command couldl be added in a later commit if this one is accepted.

smytht commented 1 year ago

OKed by Chris, OK Tom snyth