summaryrefslogtreecommitdiff
path: root/usr.bin
diff options
context:
space:
mode:
authorNicholas Marriott <nicm@cvs.openbsd.org>2012-03-22 11:11:58 +0000
committerNicholas Marriott <nicm@cvs.openbsd.org>2012-03-22 11:11:58 +0000
commitaadb8c731774443f3c939e50c31e9dcfabaa7844 (patch)
tree2685d6dd08034a24c313e2e4ead034f049e51b39 /usr.bin
parentd8351147377f8eaed15846884f79fc9e86c46dbe (diff)
Accept an argument to show-environment to show one variable, based on a
diff from Kazuhiko Sakaguchi.
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/tmux/cmd-show-environment.c19
-rw-r--r--usr.bin/tmux/tmux.18
2 files changed, 22 insertions, 5 deletions
diff --git a/usr.bin/tmux/cmd-show-environment.c b/usr.bin/tmux/cmd-show-environment.c
index 3108f5ecf95..1de64ad5dfe 100644
--- a/usr.bin/tmux/cmd-show-environment.c
+++ b/usr.bin/tmux/cmd-show-environment.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: cmd-show-environment.c,v 1.4 2011/04/05 19:37:01 nicm Exp $ */
+/* $OpenBSD: cmd-show-environment.c,v 1.5 2012/03/22 11:11:57 nicm Exp $ */
/*
* Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -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);
diff --git a/usr.bin/tmux/tmux.1 b/usr.bin/tmux/tmux.1
index 40e0b695328..bab48a664b0 100644
--- a/usr.bin/tmux/tmux.1
+++ b/usr.bin/tmux/tmux.1
@@ -1,4 +1,4 @@
-.\" $OpenBSD: tmux.1,v 1.285 2012/03/20 17:09:48 nicm Exp $
+.\" $OpenBSD: tmux.1,v 1.286 2012/03/22 11:11:57 nicm Exp $
.\"
.\" Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
.\"
@@ -14,7 +14,7 @@
.\" IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
.\" OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
.\"
-.Dd $Mdocdate: March 20 2012 $
+.Dd $Mdocdate: March 22 2012 $
.Dt TMUX 1
.Os
.Sh NAME
@@ -2908,12 +2908,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