A
A
Alexey Yarkov2017-01-20 23:22:44
bash
Alexey Yarkov, 2017-01-20 23:22:44

How to use bash inside a Makefile?

I'm trying to write a test section:

BINNAME = passgen
BIN_DIR = ./bin

...
test:
  make
  @len=$($(BIN_DIR)/$(BINNAME) -l20 -ds | wc -m)
  @[ $$len -eq '21' ] && echo "[PASSGEN TEST] OK" || echo "[PASSGEN TEST] ERROR"

If you run the commands directly in the console, then everything is OK.
And now he writes:
$ make test
/bin/bash: строка 0: [: -eq: ожидается использование унарного оператора
[PASSGEN TEST] ERROR

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Alexey Yarkov, 2017-01-20
@yarkov

Solved the problem like this:

test:
  make
  @test $$($(BINDIR)/$(BINNAME) -l20 -ds | wc -m) == '21' && echo "[PASSGEN TEST] OK" || echo "[PASSGEN TEST] ERROR"

J
jcmvbkbc, 2017-01-21
@jcmvbkbc

Solution for the original question: add the line
SHELL = /bin/bash to the Makefile

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question