In-reply-to » The “Matrix Experiment”, i.e. running a Matrix server for our family, has failed completely and miserably. People don’t accept it. They attribute unrelated things to it, like “I can’t send messages to you, I don’t reach you! It doesn’t work!” Yes, you do, I get those messages, I just don’t reply quickly enough because I’m at work or simply doing something else.

@bender@twtxt.net Sigh. 🫤 Elon Musk should buy Meta. Problem solved. 🤣

⤋ Read More
In-reply-to » The “Matrix Experiment”, i.e. running a Matrix server for our family, has failed completely and miserably. People don’t accept it. They attribute unrelated things to it, like “I can’t send messages to you, I don’t reach you! It doesn’t work!” Yes, you do, I get those messages, I just don’t reply quickly enough because I’m at work or simply doing something else.

WhatsApp locked me out of my test account for violating their TOS. Huh? I hardly even used it? Or is that the violation – not immediately feeding them with all available data about my private life? 🤣

⤋ Read More
In-reply-to » And errors out expectedly using dash or ash, very nice POSIX Sh compliant shells:

@prologic@twtxt.net Yeah, that is part of the problem. Bash is so dominant on Linux, it’s hard to avoid. When I use #!/bin/sh, it still gets me a Bash that does NOT enter strict POSIX mode. 🫤 The script below uses Bashisms and requests #!/bin/sh but still runs happily …

#!/bin/sh

foo=1

if [[ "$foo" == 1 ]]
then
    echo match
fi

⤋ Read More
In-reply-to » I love shell scripts because they’re so pragmatic and often allow me to get jobs done really quickly.

@falsifian@www.falsifian.org Exactly! 🥳

So this works:

$ bash -c 'set -u; bar=1; foo=$bar; if [[ "foo" -eq "bar" ]]; then echo it matches; fi'
it matches

Without the misleading quotes:

$ bash -c 'set -u; bar=1; foo=$bar; if [[ foo -eq bar ]]; then echo it matches; fi'
it matches

As does this:

$ bash -c 'set -u; bar=1; foo=$bar; if (( foo == bar )); then echo it matches; fi'
it matches

What the person originally meant was what bender said:

$ bash -c 'set -u; foo=bar; if [[ "$foo" = "bar" ]]; then echo it matches; fi'
it matches

It’s all rather easy once you’ve understood it … but the initial error message of the initial version can be quite unexpected.

⤋ Read More

I love shell scripts because they’re so pragmatic and often allow me to get jobs done really quickly.

But sadly they’re full of pitfalls. Pitfalls everywhere you look.

Today, a coworker – who’s highly skilled, not a newbie by any means – ran into this:

$ bash -c 'set -u; foo=bar; if [[ "$foo" -eq "bar" ]]; then echo it matches; fi'
bash: line 1: bar: unbound variable

Why’s that happening? I know the answer. Do you? 😂

Stuff like that made me stop using shell scripts at work, unless they’re just 4 or 5 lines of absolutely trivial code. It’s now Python instead, even though the code is often much longer and clunkier, but at least people will understand it more easily and not trip over it when they make a tiny change.

⤋ Read More