Rebane on Nostr: fun linux fact: the `if` shell built-in just executes the command you give it and ...
fun linux fact:
the `if` shell built-in just executes the command you give it and looks at its exit code
so how can you do stuff like `if [ $a -gt 10 ]`?
well, [ is just a program usually in /bin/[ that takes the arguments ($a, -gt, 10, ]) and returns an exit code accordingly
this is also why you need the spaces between everything as well as quoting - they're ordinary arguments and need to be provided as such
also note that many shells do actually have similar shell built-ins such as [[ ]] and (( )), which are not stand-alone programs like [ is
Published at
2026-03-09 15:46:42 UTCEvent JSON
{
"id": "5b414567ec311a5c0b09102e77f62db0b03ba0bd35a042be1843b0a7a348d426",
"pubkey": "6976b82af7e2a46a585b6743b0b57f10997884284833ef7b9d9a7e2a41c51f00",
"created_at": 1773071202,
"kind": 1,
"tags": [
[
"proxy",
"https://infosec.exchange/users/rebane2001/statuses/116199994300613385",
"activitypub"
],
[
"client",
"Mostr",
"31990:6be38f8c63df7dbf84db7ec4a6e6fbbd8d19dca3b980efad18585c46f04b26f9:mostr",
"wss://relay.ditto.pub"
]
],
"content": "fun linux fact:\nthe `if` shell built-in just executes the command you give it and looks at its exit code\n\nso how can you do stuff like `if [ $a -gt 10 ]`?\n\nwell, [ is just a program usually in /bin/[ that takes the arguments ($a, -gt, 10, ]) and returns an exit code accordingly\n\nthis is also why you need the spaces between everything as well as quoting - they're ordinary arguments and need to be provided as such\n\nalso note that many shells do actually have similar shell built-ins such as [[ ]] and (( )), which are not stand-alone programs like [ is",
"sig": "58df49c8ab9c644e89feed18ee5789200013a9f30ab3c7882856aa6f1559f0751e0943c8b90600af799f864663193af2b2ff2bff4cd74dcc04c00e70863f3c3a"
}