Jump to content

syntax error: unexpected end of file (issue with if $x = true)


Recommended Posts

Posted

for some reason a script I have fails with a syntax error. Unfortunately no further explanation of what or where the syntax error is:

~$ sudo bash *****.bash test1 *****.bash: line 13: syntax error: unexpected end of file

I have been able to reproduce the issue with this minimal script:

#!/bin/bash # option vars silentInstallation=true # work in progress apt_options=() echo "test1" if [ "$silentInstallation" = true ] then echo "choosing silent installation" apt_options=(-qq) fi echo "updating packages"

The script seems to do fine until if [ "$silentInstallation" = true ]

I have looked at other questions but cannot find the following things:

no open parentheses

no unclosed if statement

no missing line break

I am quite sure this script worked before.

Just now, sanctiondecision said:

for some reason a script I have fails with a syntax error. Unfortunately no further explanation of what or where the syntax error is:

~$ sudo bash *****.bash test1 *****.bash: line 13: syntax error: unexpected end of file

I have been able to reproduce the issue with this minimal script:

#!/bin/bash # option vars silentInstallation=true # work in progress apt_options=() echo "test1" if [ "$silentInstallation" = true ] then echo "choosing silent installation" apt_options=(-qq) fi echo "updating packages"

The script seems to do fine until if [ "$silentInstallation" = true ]

I have looked at other questions but cannot find the following things:

no open parentheses

no unclosed if statement

no missing line break

I am quite sure this script worked before.

Unexpected end of file error

thanks in advance for any help

Posted

[ @sanctiondecision ]
---

Quote

unexpected end of file

Judging from this, it looks like the bash file you created has a problem with EOL (End of Line). Since bash is based on UNIX, you need to do EOL conversion from DOS to UNIX. The difference: DOS (Windows) uses CRLF as it's end of line, UNIX (Linux) uses LF and Machintosh uses CR.
---
Please put your code under "Code (<>)" markings for readability.
---

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.