diff options
author | Tiago Cunha <tcunha@gmx.com> | 2012-03-29 21:10:10 +0000 |
---|---|---|
committer | Tiago Cunha <tcunha@gmx.com> | 2012-03-29 21:10:10 +0000 |
commit | faf51d748e6567a74df43ef5bde4c2a02f813433 (patch) | |
tree | faa211302a0fea776016539502b705dd27a9dda0 | |
parent | 407f66ccbc10919ba8494abbd2c7b43954da0429 (diff) |
Sync OpenBSD patchset 1079:
Accept an argument to show-environment to show one variable, based on a
diff from Kazuhiko Sakaguchi.
-rw-r--r-- | cmd-show-environment.c | 17 | ||||
-rw-r--r-- | tmux.1 | 4 |
2 files changed, 19 insertions, 2 deletions
diff --git a/cmd-show-environment.c b/cmd-show-environment.c index 9c065b22..1eb8fc31 100644 --- a/cmd-show-environment.c +++ b/cmd-show-environment.c @@ -31,8 +31,8 @@ int cmd_show_environment_exec(struct cmd *, struct cmd_ctx *); const struct cmd_entry cmd_show_environment_entry = { "show-environment", "showenv", - "gt:", 0, 0, - "[-g] " CMD_TARGET_SESSION_USAGE, + "gt:", 0, 1, + "[-g] " CMD_TARGET_SESSION_USAGE " [name]", 0, NULL, NULL, @@ -55,6 +55,19 @@ cmd_show_environment_exec(struct cmd *self, struct cmd_ctx *ctx) env = &s->environ; } + if (args->argc != 0) { + envent = environ_find(env, args->argv[0]); + if (envent == NULL) { + ctx->error(ctx, "unknown variable: %s", args->argv[0]); + return (-1); + } + if (envent->value != NULL) + ctx->print(ctx, "%s=%s", envent->name, envent->value); + else + ctx->print(ctx, "-%s", envent->name); + return (0); + } + RB_FOREACH(envent, environ, env) { if (envent->value != NULL) ctx->print(ctx, "%s=%s", envent->name, envent->value); @@ -2912,12 +2912,16 @@ new process. .It Xo Ic show-environment .Op Fl g .Op Fl t Ar target-session +.Op Ar variable .Xc .D1 (alias: Ic showenv ) Display the environment for .Ar target-session or the global environment with .Fl g . +If +.Ar variable +is omitted, all variables are shown. Variables removed from the environment are prefixed with .Ql - . .El |