0

Below is a section from the Makefile where I wanted to assign the output of poetry show -v | awk 'FNR <= 1' | awk 'FNR <= 1' | cut -d':' -f 2 | xargs; to the variable PP, but the value is never assigned, as in the output below

Makefile

install:
    poetry install; \
    poetry show -v | awk 'FNR <= 1' | cut -d':' -f 2 | xargs; \
    PP=$(poetry show -v | awk 'FNR <= 1' | cut -d':' -f 2 | xargs); \
    echo $$PP; \
    source $$PP/bin/activate

Output

(venv) ➜  xxxxxxx git:(main) ✗ make install
poetry install; \
        poetry show -v | awk 'FNR <= 1' | cut -d':' -f 2 | xargs; \
        PP=; \
        echo $PP; \
        source $PP/bin/activate
Installing dependencies from lock file

No dependencies to install or update
/Users/xxxxx/ssa/code/xxxxxxx/.venv

/bin/sh: /bin/activate: No such file or directory

Any help appreciated.. Thanks.

Somasundaram Sekar
  • 5,244
  • 6
  • 43
  • 85
  • `awk 'FNR <= 1' | awk 'FNR <= 1'` looks like a really unobvious way to write `head -n 1` ... or more precisely `head -n 1 | head -n 1` – tripleee Jan 23 '21 at 17:32
  • Forgive me, I'm not a shell script expert, not even close :) – Somasundaram Sekar Jan 23 '21 at 17:34
  • 1
    `$(poetry show -v ...` will be evaluated by `make` when it reads the `makefile`. To defer execution to the shell try `$$(poetry show -v ...` instead. – G.M. Jan 23 '21 at 17:34

0 Answers0