Im having trouble with cygwin not running my script file as expected
here is my code
#!/bin/sh
echo "Ja eller nei:"
read svar
if ["$svar" = "ja"]; then
echo "Du er Positiv"
exit 0
elif ["$svar" = "nei"]; then
echo "Du er Negativ"
exit 0
else
echo "Du er Nøytral"
fi
and here is my outputin cygwin
$ /cygdrive/c/MyScripts/Bash.sh
Ja eller nei:
ja
': not a valid identifierh.sh: line 6: read: `svar
/cygdrive/c/MyScripts/Bash.sh: line 10: syntax error near unexpected token `elif'
'cygdrive/c/MyScripts/Bash.sh: line 10: `elif ["$svar" = "nei"]; then
its the 3 last error lines i dont understand per say. i understand where the error’s are but not why they are there.
BTW the reason im saying some is
for i in {1..100}; do echo $i; done
works properly
Try forming your test statements with correct spacing:
This is the output I get:
Update (thanks Sorpigal):
Also, make sure your file has proper unix line endings: