sh - How can I assign command output to a variable in GNU make target rule? -
at bash prompt, can following:
~/repo$ history_log=$(git log $(get_old_version)..$(get_new_version)); [[ ! -z ${histor_log} ]] && ( echo "some header"; echo "${history_log}" )
where git log
demonstrably simplified version of have.
in make file have following command part of target:
$(output): $(input) ... echo "some header" > $(log_file) git log $(shell get_old_version)..$(shell get_new_version) >> $(log_file)
how can rewrite make target behave bash command?
if following line-feeds being stripped:
$(output): $(input) ... history_log="$(shell git log $(shell get_old_version)..$(shell get_new_version))" ; \ [ -z "$${history_log}" ] && \ true || \ (echo "some header" ; echo "$${history_log}" )
when run looks like:
~/repo $ make commit 2b4d87b0e64d129028c1a7a0b46ccde2f42c5e93 author: jamie <jamie@mymail.com> date: mon jun 25 18:46:27 2012 -0400 issue #468: sucker's been sped up.
and prefer be:
~/repo $ make commit 2b4d87b0e64d129028c1a7a0b46ccde2f42c5e93 author: jamie <jamie@mymail.com> date: mon jun 25 18:46:27 2012 -0400 issue #468: sucker's been sped up.
i think issue make
executes commands in /bin/sh
, not /bin/bash
. regardless i'm looking portable solution if there one.
make's shell
eating newlines. stop using it. instead of $( shell get_old_version )
, escape $
:
$$( get_old_version )
Comments
Post a Comment