Hi

I'm happy to have unambiguous output but I think we should only have one
style.

So better to change the existing format to be unambiguous, if possible
in a way that is fairly backwards compatible and can easily be changed
into sh form using sed.


On Sun, Aug 18, 2013 at 11:01:39AM -0400, Aaron Schrab wrote:
> At 14:49 +0100 18 Aug 2013, Nicholas Marriott <nicholas.marri...@gmail.com> 
> wrote:
> >How do you show the difference between an empty value and one to
> >be unset then?
> 
> An empty value would still have a pair of single quotes after the
> equal sign, an unset value would not.
> 
> But, I'm now thinking that I should change it to emit "unset var"
> for the latter case.  Here's a patch on top of the previous one to
> accomplish that.  If these changes get applied, it may make sense to
> squash the two changes into one.
> 
> ------ 8< -------
> 
> Subject: [PATCH] Unset variables in showenv -s output
> 
> In order for showenv -s output to truly replicate the effect if eval'd
> by a shell, variables that aren't set need to be explicitly unset not
> just set to an empty value.
> ---
> cmd-show-environment.c |   17 +++++++++--------
> 1 file changed, 9 insertions(+), 8 deletions(-)
> 
> diff --git a/cmd-show-environment.c b/cmd-show-environment.c
> index 31058af..a49a1c2 100644
> --- a/cmd-show-environment.c
> +++ b/cmd-show-environment.c
> @@ -48,10 +48,12 @@ sh_environment( struct cmd_q *cmdq, struct environ_entry 
> *envent )
>       size_t  len;
>       size_t  bufsize = 128;
> 
> -     val = buf = xmalloc(bufsize);
> -
> -     if (envent->value != NULL) {
> +     if (envent->value == NULL) {
> +             cmdq_print(cmdq, "unset %s", envent->name);
> +     }
> +     else {
>               old = envent->value;
> +             val = buf = xmalloc(bufsize);
>               *(val++) = '\'';
>               len = 1;
> 
> @@ -78,12 +80,11 @@ sh_environment( struct cmd_q *cmdq, struct environ_entry 
> *envent )
>                       ++len;
>               }
>               *(val++) = '\'';
> -     }
> -
> -     *val = 0;
> -     cmdq_print(cmdq, "%s=%s", envent->name, buf);
> +             *val = 0;
> 
> -     free(buf);
> +             cmdq_print(cmdq, "%s=%s", envent->name, buf);
> +             free(buf);
> +     }
> }
> 
> enum cmd_retval
> -- 
> 1.7.10.4
> 

------------------------------------------------------------------------------
Introducing Performance Central, a new site from SourceForge and 
AppDynamics. Performance Central is your source for news, insights, 
analysis and resources for efficient Application Performance Management. 
Visit us today!
http://pubads.g.doubleclick.net/gampad/clk?id=48897511&iu=/4140/ostg.clktrk
_______________________________________________
tmux-users mailing list
tmux-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/tmux-users

Reply via email to