Skip to content
Advertisement

Piping two command from makefile is not working

I use the following commands in my makefile

apps := $(shell fzr provide apps )
apps := $(subst ],,$(subst [,,$(apps)))

in the commands im getting array of values and remove the array [] from it,

I want to run this command in my terminal and I use the following

fzr provide apps | (subst ],,$(subst [,,$(apps))) | $(apps)

and I got error

bash: apps: command not found
bash: apps: command not found
bash: subst: command not found
bash: subst: command not found

what am I missing here ?

if I run only

fzr provide apps

I got, which works

[app1 app2 app3]

The idea is to inspect command

apps := $(subst ],,$(subst [,,$(apps)))

which works on mac but in windows it’s not …

Advertisement

Answer

The commands which are valid in a Makefile are not valid on the terminal prompt.

If you want to remove the leading and trailing square brackets in a Bash script, try

fzr provide apps |
sed 's/^[//;s/]$//'

If you want to put that in a Makefile, note that you will need to double the dollar sign (a single dollar sign gets evaluated by make itself; doubling it passes through a literal dollar sign to the shell).

apps := $(shell fzr provide apps | sed 's/^[//;s/]$$//')

Your Makefile uses syntax which is specific to GNU Make; perhaps the make version you have on Windows is not a GNU-compatible one.

User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement