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

Re: globbing in conditional expressions



On May 26, 11:52pm, Daniel Shahaf wrote:
}
} 
} Bart Schaefer wrote on Thu, May 15, 2014 at 07:50:03 -0700:
} > adding a globbing flag (#X) [where I'm using X as a placeholder rather
} > than a suggestion for the actual flag] which means that the glob returns
} > only the first matching file it stumbles upon.
} > 
} > In fact if you had that flag you wouldn't need -m as a condition op, it
} > would suffice to do [ ! -z pat(NX) ].
} 
} That turned out to be much less code to implement.  It's attached, if
} anyone finds it useful.

I like this one.  Is there a mnemonic for your choice of (Y) ?

} I couldn't get it to work via [ -z ]

Hmm, seems to work for me:

torch% print co*
config.h config.log config.modules config.modules.sh config.status
torch% print co*(Y)
config.h
torch% print ba*   
zsh: no matches found: ba*
torch% [ -z ba*(N) ] && echo OK 
OK
torch% [ ! -z ba*(NY) ] && echo OK
torch% [ ! -z co*(NY) ] && echo OK
OK


To zsh-workers:  Any reason not to commit/push this?



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