On Sun, Nov 17, 2024 at 04:59:34PM +0100, Kirill A. Korinsky wrote:
> >Synopsis: ksh: syntax error: `(' unexpected
> >Category: ksh
> >Environment:
> System : OpenBSD 7.6
> Details : OpenBSD 7.6-current (GENERIC.MP) #39: Sun Nov 17 11:27:14
> CET 2024
>
> [email protected]:/usr/src/sys/arch/amd64/compile/GENERIC.MP
>
> Architecture: OpenBSD.amd64
> Machine : amd64
> >Description:
> ksh -n complains as syntax error on legitim shell script.
> >How-To-Repeat:
> echo 'login() { login }' | ksh -n -
> >Fix:
> No idea
>
> --
> wbr, Kirill
A the final right curly brace of a compound command must be preceeded by
a command terminator, most commonly a newline or a semi-colon. This is
what causes the syntax error in the script.
An additional issue is that your login function would call itself,
causing an infinite recursion. To prevent this, call "login" as
"command login" in the function body.
--
Andreas (Kusalananda) Kähäri
Uppsala, Sweden
.