I expected this file to echo "error" and exit. Why does it produce the unexpected end of file error instead? I used vim to create the file.
#!/bin/bash
{ eval "nothing" } || { echo "error" ; exit 1 }
echo "something"
CodePudding user response:
}
is only special in command position. In your code, each }
is just another argument to the preceding eval
and exit
commands. Nothing ever closed the opening {
.
You need to first terminate the preceding commands explicitly, for example, with a ;
.
{ eval "nothing"; } || { echo "error" ; exit 1; }
echo "something"