Skip to content

cannot run multi-line bash command #8

@w1475963

Description

@w1475963

when: I paste muti-line bash script into terminal

example:

for ((i=0; i<5; i++)); do
    echo "$i"
done

error:

bash: eval: line 2: syntax error: unexpected end of file from `for' command on line 1

It seems that the issue occurred because a ; was not added when multiple lines of text were merged into one line.

# error(one line)
for ((i=0; i<5; i++)); do echo "$i" done

# success(one line)
for ((i=0; i<5; i++)); do echo "$i" ; done
# It can also run successfully when pasted into fish

btw, if the first line starts with #, it will not be executed either (may be the same reason).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions