Conversation

in linux you can use the evil bird emoticon (:>) to destroy files, eg `:> important_document.txt`

the bird will eat the file and leave it completely empty!

2
6
0

@rebane2001 hmm I suppose thats because its writing nothing into the file but I dont understand the reason for the : (I mean yeah it does make the face but from a commands perspective I mean)

Id assume it works without?

Im guessing : is ignored or perhaps written into the file?

3
0
0

@lambda @ChaosKitsune @rebane2001 does that like actually run the no-op in assembly//machine level ?? or actually do nothing and return 0 ??

1
0
0

@pinkRhododendron @ChaosKitsune @rebane2001 the latter, there's no reason the *implementation* of the shell built-in would have to use an extra machine instruction that does nothing (though maybe the compiler sneakily inserts one anyway, e.g. for alignment reasons!)

0
0
0

@ChaosKitsune it's a bash builtin
$ help :
:: :
Null command.

No effect; the command does nothing.

Exit Status:
Always succeeds.

@rebane2001

0
0
0

@ChaosKitsune https://www.gnu.org/software/bash/manual/bash.html#index-_003a

the colon is a shell command that does nothing

it’s often used to perform expansions with side-effects, like:

: ${ARGUMENT:=default value}
: ${MUST_BE_SET:?error message}

@rebane2001

1
0
0

@jcpandrade ha! I tend to do while true because it reads better to me
(yes, I know that involves a fork+exec, but if we cared about speed we wouldn’t be writing shell)
@ChaosKitsune @rebane2001

1
0
0

@dakkar I used the true but... : is faster and easier to type... Just being lazy, I admit. @ChaosKitsune @rebane2001

0
0
0
@rebane2001 technically, it will only steal your file, not destroy it. Which, I guess, means that :> is a corvid.
0
0
2