2

I'd like to assign a variable in a Tupfile the output of the command find . -name "*.cpp" -exec dirname {} \; | sort -u. How can I do it?

e271p314
  • 3,841
  • 7
  • 36
  • 61

2 Answers2

1

This works for me:

BOTAN_CFLAGS = `pkg-config botan-1.10 --cflags`

NOTE: the back-tick character "`"

However this only seems to work in the command section of the rules not the dependencies.

Galik
  • 47,303
  • 4
  • 80
  • 117
  • According to https://man.archlinux.org/man/community/tup/tup.1.en#var~2 this doesn't actually work, it just passes the string, backticks and all, to whatever uses it. – Adam J Richardson Jan 23 '23 at 19:32
  • 1
    @AdamJRichardson Yes, but if you read further, the command will be passed to the shell when the variable is used later by a command. It is unclear what the OP's use case was, but I assume it was compatible with my answer as he gave me a tick :) – Galik Jan 23 '23 at 20:18
1

From what I read in the manual, the variable assignment does not cause the shell command to be executed. Instead, it is stored as regular string. Then when the variable is passed to a command, the shell expands it. It means that if you have K files to compile, the shell expression will be evaluated K times.

Noam Cohen
  • 11
  • 1