Reputation: 642
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
Upvotes: 8
Views: 16006
Reputation: 123
I hade the same error where I put double quotes string in an already double quoted command in the .bashrc file. It was in a multi-line command and I didn't notice it at first.
Doesn't work:
alias my_command="echo "doublequoted string example no no""
Works:
alias my_command='echo "doublequoted string example yes yes"'
Upvotes: 0
Reputation: 642
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.
Upvotes: 5