Hi

I tweaked this a bit so the output format is the same for one or many
variables and applied it, thanks!


On Wed, Mar 21, 2012 at 05:45:34PM +0900, Kazuhiko Sakaguchi wrote:
> Hi
> 
> Thanks!  The attached patch fixed the bug.
> 
> 2012/3/17 Nicholas Marriott <nicholas.marri...@gmail.com>:
> > Hi
> >
> > I think that when you print a single option you need to check
> > envent->value is not NULL (meaning the variable is removed from
> > environment), same as inside the loop.
> >
> > Also this patch doesn't apply, I guess your mailer is mangling it. Can
> > you try to send it as an attachment instead?
> >
> >
> >
> > On Sat, Mar 17, 2012 at 03:17:14AM +0900, Kazuhiko Sakaguchi wrote:
> >> Hi,
> >>
> >> Thanks for the feedback.
> >> I rewrote the patch. ?It adds a optional argument to show-environment.
> >>
> >> --- 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,11 +55,21 @@ cmd_show_environment_exec(struct cmd *self, struct
> >> cmd_ctx *ctx)
> >> ? ? ? ? ? ? ? env = &s->environ;
> >> ? ? ? }
> >>
> >> - ? ? RB_FOREACH(envent, environ, env) {
> >> - ? ? ? ? ? ? if (envent->value != NULL)
> >> - ? ? ? ? ? ? ? ? ? ? ctx->print(ctx, "%s=%s", envent->name, 
> >> envent->value);
> >> - ? ? ? ? ? ? else
> >> - ? ? ? ? ? ? ? ? ? ? ctx->print(ctx, "-%s", envent->name);
> >> + ? ? if (args->argc != 0){
> >> + ? ? ? ? ? ? envent = environ_find(env, args->argv[0]);
> >> + ? ? ? ? ? ? if (envent == NULL){
> >> + ? ? ? ? ? ? ? ? ? ? ctx->error(ctx, "entry not found");
> >> + ? ? ? ? ? ? ? ? ? ? return (-1);
> >> + ? ? ? ? ? ? }
> >> + ? ? ? ? ? ? ctx->print(ctx, envent->value);
> >> + ? ? }
> >> + ? ? else {
> >> + ? ? ? ? ? ? RB_FOREACH(envent, environ, env) {
> >> + ? ? ? ? ? ? ? ? ? ? if (envent->value != NULL)
> >> + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ctx->print(ctx, "%s=%s", envent->name, 
> >> envent->value);
> >> + ? ? ? ? ? ? ? ? ? ? else
> >> + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ctx->print(ctx, "-%s", envent->name);
> >> + ? ? ? ? ? ? }
> >> ? ? ? }
> >>
> >> ? ? ? return (0);
> >>
> >> 2012/3/13 Nicholas Marriott <nicholas.marri...@gmail.com>:
> >> > Hi
> >> >
> >> > Looks good but I think there is no need for -n, just use the first
> >> > argument if argc != 0, like the recent changes to show-option.
> >> >
> >> > Thanks
> >> >
> >> >
> >> > On Tue, Mar 13, 2012 at 06:56:34AM +0900, Kazuhiko Sakaguchi wrote:
> >> >> Hi,
> >> >>
> >> >> This patch add a -n argument to show-environment. ?It specifies a 
> >> >> variable name.
> >> >>
> >> >> example:
> >> >> $ tmux show-environment -g -n TERM
> >> >> rxvt-unicode-256color
> >> >>
> >> >> --- 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:n:", 0, 0,
> >> >> + ? ? "[-g] " CMD_TARGET_SESSION_USAGE " [-n name]",
> >> >> ? ? ? 0,
> >> >> ? ? ? NULL,
> >> >> ? ? ? NULL,
> >> >> @@ -46,6 +46,7 @@ cmd_show_environment_exec(struct cmd *self, struct
> >> >> cmd_ctx *ctx)
> >> >> ? ? ? struct session ? ? ? ? ?*s;
> >> >> ? ? ? struct environ ? ? ? ? ?*env;
> >> >> ? ? ? struct environ_entry ? ?*envent;
> >> >> + ? ? const char ? ? ? ? ? ? ?*name;
> >> >>
> >> >> ? ? ? if (args_has(self->args, 'g'))
> >> >> ? ? ? ? ? ? ? env = &global_environ;
> >> >> @@ -55,11 +56,22 @@ cmd_show_environment_exec(struct cmd *self, struct
> >> >> cmd_ctx *ctx)
> >> >> ? ? ? ? ? ? ? env = &s->environ;
> >> >> ? ? ? }
> >> >>
> >> >> - ? ? RB_FOREACH(envent, environ, env) {
> >> >> - ? ? ? ? ? ? if (envent->value != NULL)
> >> >> - ? ? ? ? ? ? ? ? ? ? ctx->print(ctx, "%s=%s", envent->name, 
> >> >> envent->value);
> >> >> - ? ? ? ? ? ? else
> >> >> - ? ? ? ? ? ? ? ? ? ? ctx->print(ctx, "-%s", envent->name);
> >> >> + ? ? name = args_get(self->args, 'n');
> >> >> + ? ? if (name != NULL){
> >> >> + ? ? ? ? ? ? envent = environ_find(env, name);
> >> >> + ? ? ? ? ? ? if (envent == NULL){
> >> >> + ? ? ? ? ? ? ? ? ? ? ctx->error(ctx, "entry not found");
> >> >> + ? ? ? ? ? ? ? ? ? ? return (-1);
> >> >> + ? ? ? ? ? ? }
> >> >> + ? ? ? ? ? ? ctx->print(ctx, envent->value);
> >> >> + ? ? }
> >> >> + ? ? else {
> >> >> + ? ? ? ? ? ? RB_FOREACH(envent, environ, env) {
> >> >> + ? ? ? ? ? ? ? ? ? ? if (envent->value != NULL)
> >> >> + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ctx->print(ctx, "%s=%s", envent->name, 
> >> >> envent->value);
> >> >> + ? ? ? ? ? ? ? ? ? ? else
> >> >> + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ctx->print(ctx, "-%s", envent->name);
> >> >> + ? ? ? ? ? ? }
> >> >> ? ? ? }
> >> >>
> >> >> ? ? ? return (0);
> >> >>
> >> >> ------------------------------------------------------------------------------
> >> >> Try before you buy = See our experts in action!
> >> >> The most comprehensive online learning library for Microsoft developers
> >> >> is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
> >> >> Metro Style Apps, more. Free future releases when you subscribe now!
> >> >> http://p.sf.net/sfu/learndevnow-dev2
> >> >> _______________________________________________
> >> >> tmux-users mailing list
> >> >> tmux-users@lists.sourceforge.net
> >> >> https://lists.sourceforge.net/lists/listinfo/tmux-users
> >



------------------------------------------------------------------------------
This SF email is sponsosred by:
Try Windows Azure free for 90 days Click Here 
http://p.sf.net/sfu/sfd2d-msazure
_______________________________________________
tmux-users mailing list
tmux-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/tmux-users

Reply via email to