The
`var=value cmd ar1`
syntax doesn't quite seem to work if `cmd` is a for loop (in neither `bash` nor `sh`).
Both `sh` and `bash` give syntax errors for:
foo=bar for f in ${foo:-BAR}; do echo $f; done
which is what you're esentially doing.
(
* sh: 1: for: not found
* bash: syntax error near unexpected token `do'
)
And that error seems to result in a `couldn't find fi` error in your case;
Setting the variable on a separate line fixes the syntax error:
kernlist=$(awk '$1 == "config" { print $2 }' ${kernelconfpath})
for kern in ${kernlist:-netbsd}; do #...
**Note:**
I would just write `"$kernelbuildpath/$kern"` instead of `"${kernelbuildpath}/${kern}"` if I were you. There's no technical reason for the curlies.