I have a function that I minified to debug but I cannot see the problem. Here is the minimal code to reproduce the issue:
#!/bin/zsh
ahead=1
if [[ "$ahead" -ne 0 ]]; then
echo "test"
else
echo "testelse"
fi
I get from executing this script:
./test:4: bad pattern :[[ 1
I cannot understand where the problem is. If I test it with tio.run, it works! If I copy paste it in console it also works.
If I remove the shebang I get:
./test: line 2: [[ 1: command not found
testelse
I don't really know how or why but as @justsomebody pointed out in the comments it was some kind of weird whitespace character between [[
and $ahead
. Might be vim or something else, if you have any clue what it could have been, it would be nice to know.
Edit: I will add that altgr + space
creates the kind of character that leads to this situation.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With