Re: no match should be no string ?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 28/11/2021 14:11, Marc Chantreux wrote:
hello people,

I'm porting scripts from zsh to dash using version
0.5.11+git20200708+dd9ef66-5 from debian and
surprised to realize that the result of a glob failure is the glob
itself (when i expected an empty string).

Hi, yes, this is expected, this is standard POSIX sh behaviour and implemented by all POSIX sh-compatible shells. It should even be what zsh does when running in POSIX mode, but I do not have it installed right now to check.

In bash, it is optional, you get the glob itself by default, but there is a "nullglob" shell option you can set to get what you are asking for.

In ksh, it is optional, you get the glob itself by default, but there is a special thing where you can start a glob with ~(N) to change only that glob only to expand to nothing if there is no match.

Both of those are valid extensions that don't affect POSIX conformance.

I personally suspect dash will not want to implement either extension until POSIX decides which extension, if either/any, to standardise at some point.

Cheers,
Harald van Dijk



[Index of Archives]     [LARTC]     [Bugtraq]     [Yosemite Forum]     [Photo]

  Powered by Linux