Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm
Precedence: bulk
X-No-Archive: yes
List-Id: Zsh Workers List <zsh-workers.zsh.org>
List-Post: <mailto:zsh-workers@zsh.org>
List-Help: <mailto:zsh-workers-help@zsh.org>
X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on f.primenet.com.au
X-Spam-Level: 
X-Spam-Status: No, score=-0.8 required=5.0 tests=BAYES_00,INVALID_DATE
	autolearn=no autolearn_force=no version=3.4.0
Date: Sun, Jan 01 2016 00:37:55 +0000
From: Daniel Shahaf <d.s@daniel.shahaf.name>
To: zsh-workers@zsh.org
Subject: Re: PATCH misc. cleanup in bin_print()
Message-ID: <20160110003755.GA6751@tarsus.local2>
References: <160104224749.ZM6378@torch.brasslantern.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
In-Reply-To: <160104224749.ZM6378@torch.brasslantern.com>
User-Agent: Mutt/1.5.23 (2014-03-12)
X-Seq: zsh-workers 37529

Bart Schaefer wrote on Mon, Jan 04, 2016 at 22:47:49 -0800:
> Is there any objection to making some of these incompatible combinations
> of print options into errors, instead of either implicit precedences or
> bugs waiting to happen?  The one I left commented out has an explicit
> Test/B03* check so I'm guessing maybe there's a reason for it.
> 

+1 (concept): I think invalid flag combinations should result in
errors, but I haven't reviewed the patch in detail.

> +++ b/Src/builtin.c
> @@ -4036,10 +4036,46 @@ bin_print(char *name, char **args, Options ops, int func)
>      zulong zulongval;
>      char *stringval;
>  
> -    if (OPT_ISSET(ops, 'z') + OPT_ISSET(ops, 's') + OPT_ISSET(ops, 'v') > 1) {
> -	zwarnnam(name, "only one of -z, -s, or -v allowed");

Should -p be in this set too?

> +    /* Error check option combinations and option arguments */
> +
> +    if (OPT_ISSET(ops, 'z') +
> +	OPT_ISSET(ops, 's') + OPT_ISSET(ops, 'S') +
> +	OPT_ISSET(ops, 'v') > 1) {
> +	zwarnnam(name, "only one of -s, -S, -v, or -z allowed");
> +	return 1;
> +    }

In retrospect it might've been better to have a single '-x foo' output
that could be '-x zle_buffer_stack', '-x parameter=foo' (sets $foo), '-x
history', etc..  (Or, come to think of it, all these should have been
exposed as things that can be |ed or >ed to, so that other things beside
'print' could write to them.)  But that train has left the station :-(

