3 ms·
This script taught me a few things! Since it's kind of impossible to google, what does this construct mean? while :; do It's clearly a while true loop, but
by sillysaurusx 5y ago
This script taught me a few things! Since it's kind of impossible to google, what does this construct mean?
while :; do
It's clearly a while true loop, but why does an ascii crying face produce true?
- veltas 5y ago: is a sort of 'null' function in bash and bourne shells. It also always returns 0 so it's an alternative to 'true'. https://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_16 https://pubs.opengroup.org/onlinepubs/9699919799/utilities/V...
- framecowbird 5y agohttps://stackoverflow.com/a/3224910 https://stackoverflow.com/a/3224910
- StanAngeloff 5y agoSee https://stackoverflow.com/questions/3224878/what-is-the-purpose-of-the-colon-gnu-bash-builtin https://stackoverflow.com/questions/3224878/what-is-the-purp... $ type : : is a shell builtin
- vultour 5y agoWhat's impossible to google about that? "bash colon" gives tons of results
- tyingq 5y agoIncluding the somewhat unexpected "Bottoms Up Bash - Colon Cancer Prevention Project".
- bewuethr 5y agoBash also has the equivalent "true" as a builtin, and Coreutils provides one as well, allowing to write this instead: while true; do
- veltas 5y agotrue is also a POSIX utility (not builtin), so it can be used in POSIX-y sh scripts as well. https://pubs.opengroup.org/onlinepubs/9699919799/utilities/true.html https://pubs.opengroup.org/onlinepubs/9699919799/utilities/t...
- mturmon 5y agoThe other common idiom in scripts that uses the : is : > $LOGFILE which creates a zero-length log file, and removes the contents if it already existed.
- Trufa 5y agoYou get decent results if you put it on quotes.
- prettyStandard 5y agoYou can search for this. https://duckduckgo.com/?q="while+%3A%3B+do"+bash https://duckduckgo.com/?q="while+%3A%3B+do"+bash