1

It is not clear to me, where the error comes from, the Makefile code follows:

platform_id = $$( uname -s )

platform = $$( \
    case $(platform_id) in \
        Linux | FreeBSD | OpenBSD | NetBSD ) echo $(platform_id) ;; \
        * ) echo Unrecognized ;; \
    esac )

and the first target in the Makefile is:

check:
    echo $(platform); echo

On both Linux Mint 19.0, and FreeBSD 11.2, it works without problem, tested with both GNU make, and BSD make. I mean on both of those systems with gmake, and bmake.

I am new to OpenBSD 6.4, and being unable to find the cause of the error is frustrating.

The error message with the command follows:

echo $(  case $( uname -s ) in Linux | FreeBSD | OpenBSD | NetBSD ) echo $( uname -s ) ;; * ) echo Unrecognized ;;  esac ); echo
/bin/sh: syntax error: ';;' unexpected
*** Error 1 in /root (Makefile:47 'check')

As I don't have guest additions installed yet, I must have transcripted but checked twice, it should be correct.

2

You are using a shell with a broken parser....

Background: parsing $(command) needs a recursive parser to work correctly.

Note that the complete expression $(command) needs to be in a single string and command can be really complex. To find the end of the command, modern shells recursively call the parser and let it stop at the first superfluous ). mksh and bosh then convert the binary syntax tree back into a command, while ksh93 shuffles the characters read by the recrusive parser into a buffer.

POSIX (really ksh88) at some time believed that this would work with a simple string parser that just counts ( and ) and added a requirement to add ( before the case labels.

Since your command is not OK with respect to what POSIX believes, you could retry with changing:

    Linux | FreeBSD | OpenBSD | NetBSD ) echo $(platform_id) ;; \

into:

    ( Linux | FreeBSD | OpenBSD | NetBSD ) echo $(platform_id) ;; \

and

* ) echo Unrecognized ;; \

into

( * ) echo Unrecognized ;; \

If your shell is using such a primitive counting parser, it should work with that change.

  • 1
    Upgrading OpenBSD's sh from PD Korn to 93 Korn has come up a number of times over the past couple of decades. – JdeBP Oct 23 '18 at 7:55
  • ksh93, mksh, bash and bosh would all work. PD ksh is known to be full of bugs. – schily Oct 23 '18 at 7:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.