On Sun, Nov 17, 2024 at 06:28:34PM +0100, Andreas Kähäri wrote:
> On Sun, Nov 17, 2024 at 05:52:26PM +0100, Jeremie Courreges-Anglas wrote:
> > 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
> > 
> > 'login' is already an alias:
> 
> But does that matter to the non-interactive ksh shell?

Well, it appears so.

> The actual
> issue, which you solved in your code below without actually writing
> anything about it, is the lack of command-terminator before the final
> "}" of reth function definition.

While it's true that I had silently fixed the lack of
command-terminator, "login" is affected by another problem really.
Compare:

  ritchie ~$ echo 'login() { login }' | ksh -n -
  ksh: <stdin>[1]: syntax error: `(' unexpected
  ritchie ~$ echo '\login() { login }' | ksh -n -
  ksh: <stdin>[1]: syntax error: `{' unmatched

> > 
> > ritchie ~$ command -v login
> > alias login='exec login'
> > ritchie ~$ echo '\login() { lala; }' | ksh -n -
> > ritchie ~$
> > 
> > See main.c:
> >          /* Aliases that are builtin commands in at&t */
> >       "login=exec login",
> > 
> > I guess a builtin would be slightly cleaner, but it means more code.

-- 
jca

Reply via email to