help-make
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Running case commands with the shell function?


From: Paul Smith
Subject: Re: Running case commands with the shell function?
Date: Thu, 14 Sep 2017 08:04:18 -0400

On Thu, 2017-09-14 at 13:52 +0200, Sébastien Hinderer wrote:
> Of course this does not work because the first closing parenthesis is
> interpreted as ending the call to the shell function.
> 
> Is there a way to actually achieve this, please?

You have at least three choices:

First, use the matched parenthesis form of case; this is valid POSIX
shell syntax (and I prefer it even in normal shell scripts as it makes
editor matching etc. simpler):

  case "$target" in 
      (i386-*-) echo foo ;;
      (*) ;;
  esac

Make will count the open/close parens properly.

Or second, you could use the curly-brace form of variable/function
invocation instead, like:

  ${shell ... }

so make will ignore mismatched parentheses.

Or third, you can assign a variable to the close-paren and use that
instead:

  CP := )

  $(shell ... *$(CP) ;; ...)

Make always parses to the end of the variable or function first, before
it tries to expand what's inside.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]