Whose Error Is It?
Bash printed this
bash: syntax error near unexpected token `fi'
What it meansBash reached a fi keyword that does not close a valid if block, so the if statement above it is malformed or incomplete.
The first thing to checkCheck the if line for a missing then or semicolon, like if [ "$x" ]; then, and look for Windows CRLF line endings, which break keywords.