Code: Select all
while true; do echo -n "Mrmajik45 "; done
Code: Select all
while true; do echo -n "Mrmajik45 "; done
:
is shorthand for true
.[ 1 ]
can also be used as true
, where 1 is any string.[ ]
can be used as the false
command.until
loop.for
loop, and while read
construct.Type the following:Termy wrote:More random information:
:
is shorthand fortrue
.
...
help :
or type -a :
It isn't a shorthand for true. The exit status of the shell builtin "always succeeds". In the bash man page, section "SHELL BUILTIN COMMANDS", it says:Null command.
No effect; the command does nothing.
Exit Status:
Always succeeds.
: is a shell builtin
You can do things like:: [arguments]
No effect; the command does nothing beyond expanding arguments and performing any specified redirections. A zero exit code is returned.
Code: Select all
function myFunc() {
:
}
: >"${playlist}"
type -a true
(while true; do
).Sorry if my reply was not clear.xenopeek wrote:Yet this does exactly the same as OP's command:lmuserx4849 wrote:It isn't a shorthand for true.
while :; do echo -n "Mrmajik45 "; done
Code: Select all
while
command list
do
command list
done
So doesxenopeek wrote:Sure, : doesn't equate to true, but in the loop it serves the same purpose. Without, with single or with double brackets.
while true
which is more indicative of what one is trying to accomplish true; echo $?
returns 0:; echo $?
also returns 0while :; do echo -n "Mrmajik45 "; done
which does the same as while true; do echo -n "Mrmajik45 "; done
false; echo $?
! :;echo $?
until false ; do echo -n "Mrmajik45 ";done
does the same as until ! : ; do echo -n "Mrmajik45 ";done
:(){ false; }
now if you execute this function :; echo $?
it will return status 1while :; do echo -n "Mrmajik45 "; done
unless you declare the function like this:(){ true; }
I'm aware of all that, but I think you're being pedantic here. Maybe it would've been better for me to say that it can be used as shorthand for true. : always has an exit status of zero. What xenopeek said, basically.lmuserx4849 wrote: ---