NireBryce

reality is the battlefield

the first line goes in Cohost embeds

๐Ÿฅ I am not embroiled in any legal battle
๐Ÿฆ other than battles that are legal ๐ŸŽฎ

I speak to the universe and it speaks back, in it's own way.

mastodon

email: contact at breadthcharge dot net

I live on the northeast coast of the US.

'non-functional programmer'. 'far left'.

conceptual midwife.

https://cohost.org/NireBryce/post/4929459-here-s-my-five-minut

If you can see the "show contact info" dropdown below, I follow you. If you want me to, ask and I'll think about it.

You must log in to comment.

in reply to @NireBryce's post:

can you explain this in more detail?

my understanding was that it just inverts the condition so exit code 0 fails the if statement (and the rest of the line is just a regular command rather than the bash special syntax [[

yeahh... my understanding is that [ is potentially just a regular program called test normally... but then [[ is bash-specific non-POSIX shell level syntax that fixes some of the issues related to variable expansion and whatnot

it took me a while to sort out regular if vs if [ vs if [[ in bash x_x;

right, but if you flub the negation and put it outside of [/[[, it still will do what I'm saying, which is what tripped me up

whereas in other languages, in this example python but also most others,

if not <thing>: 
    print("if") 
else: 
    print("else")

will print "if" and not "else"

bash: if [[ ! "$x" = "" ]]; then echo T; else echo F; fi
T

bash: if ! [[ "$x" = "" ]]; then echo T; else echo F; fi
T

bash: if [[ "$x" != "" ]]; then echo T; else echo F; fi
T

bash: if ! [[ "$x" = "" || "$x" = "1" ]]; then echo T; else echo F; fi
F

bash: if [[ ! "$x" = "" || "$x" = "1" ]]; then echo T; else echo F; fi
T

vs

>>> (not x == 0 or x == 1)
True

>>> not (x == 0 or x == 1)
False

>>> not x == 0
True

>>> not (x == 0)
True

>>> x != 0
True

it seems like it matches up to me with python, maybe i'm missing something ๐Ÿ˜