I don't understand why I'm getting this error? It seems like good syntax to me.
$ for f in todo/family/* ; echo "$f" ; done
zsh: parse error near `done'
The first $ is PS1 - this is on the regular "command line" - not in a file.
I don't understand why I'm getting this error? It seems like good syntax to me.
$ for f in todo/family/* ; echo "$f" ; done
zsh: parse error near `done'
The first $ is PS1 - this is on the regular "command line" - not in a file.
do in my command.As per @CharlesDuffy's comment, this is clearly a typo/missing syntax related problem.
What I wrote: for f in todo/family/* ; echo "$f" ; done
# ^ missing do
Bash expected: for f in todo/family/* ; do echo "$f" ; done
Clearly this error/typo is visible using spellcheck.net (another great resource) - thanks Charles.
#!/bin/sh
for f in todo/family/* ; echo "$f" ; done
You will see the error clearly:
$ shellcheck myscript
Line 3:
for f in todo/family/* ; echo "$f" ; done
^-- SC1073: Couldn't parse this for loop. Fix to allow more checks.
^-- SC1058: Expected 'do'.
^-- SC1072: Expected 'do'. Fix any mentioned problems and try again.
Add do with a space, just before echo and everything checks out:
#!/bin/sh
for f in todo/family/* ; do echo "$f" ; done
into spellcheck.net - you can see there is no error. Remove the do and you will see what my problem was.
shellcheck command in copious ways: