Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: 5.3: printf -



Bart Schaefer wrote on Mon, Dec 12, 2016 at 20:21:10 -0800:
> On Dec 12, 11:41pm, Daniel Shahaf wrote:
> }
> } % printf -
> } printf: not enough arguments
> } 
> } Happens in sh mode too.  dash and bash [that's what I have handy] print
> } a minus sign.
> 
> I was going to blame this on zsh generally treating a single "-" like
> "--" in argument lists (which is documented), but something is fishy:
> 
> torch% printf -- --      
> printf: not enough arguments
> torch% printf - -  
> -%
> torch% printf - --
> printf: not enough arguments
> torch% printf -- - 
> -%
> torch% printf -- -- --
> --%

I think these should:

• In sh mode, emit argv[1] and ignore the others: it is the format
  string even if it happens to start with a minus.

• In zsh mode, interpret argv[1] as end-of-options, then emit argv[2]
  and ignore any other arguments: argv[2] is the format string.

Another case: «printf -x».

> ("%" there is PROMPT_SP of course).
> 



Messages sorted by: Reverse Date, Date, Thread, Author