[kwlug-disc] The amazing colon trick in GLOB matching within [[ ]] for bash
Federer Fanatic
nafdef at gmail.com
Thu Mar 12 06:00:46 EDT 2026
When installing tools from the internet they usually have a curl download
sh script and pipe it into sh...not recommended and I never to this instead
pipe to a file and then look at the script. In any case I found this bit of
magic in one of them I was not aware of but actually needed (normally one
just uses an external command in bash, afterall it's a shell:
if [[ ":${PATH}:" == *":${HOME}/.local/bin:"* ]]; then echo YES; else echo
NO; fi
and you do not need to enable globbing via shopt, the glob pattern is not
=~ construct but a check for equality....amazing ability for bash later
versions.
--------------------------------------------------------------
Roger Federer Fanatic Extraordinaire :-)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kwlug.org/pipermail/kwlug-disc_kwlug.org/attachments/20260312/38b43ce8/attachment.htm>
More information about the kwlug-disc
mailing list