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

Re: Function names prefixed with "%"



On 5/27/22, Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx> wrote:
> On Thu, May 26, 2022 at 6:15 PM Zach Riggle <zachriggle@xxxxxxxxx> wrote:
>>
>> It seems that it's completely valid to declare a function with a leading
>> percent, but it's not able to be called due to be interpreted as job
>> control.
>
> The very first entry in Etc/BUGS says:
>
> The pattern %?* matches names beginning with %? instead of names with at
> least two characters beginning with %. This is a hack to allow %?foo job
> substitution without quoting. This behaviour is incompatible with sh
> and ksh and may be removed in the future.

I think this is unrelated, the problem Zach has is that
% %foo() { echo hi }; %foo
outputs
fg: job not found: foo

While the bug is that
% echo %?foo
outputs
%?foo
instead of
zsh: no matches found: %?foo
eg, the ? in %?* is not a pattern character effectively.

You can combine these two problems but the result is quite anti-synergistic:
% %?foo() { echo hi }
% %?foo
fg: job not found: ?foo
% echo %?foo
%?foo

-- 
Mikael Magnusson




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