Last active
August 29, 2022 11:20
-
-
Save guitarrapc/71255f60a4d26f0e8ffe8cd8ca9a100f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CLIBS = "" | |
foo: | |
@echo "CLIBS is '${CLIBS}'" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
set -e | |
# echo command & execute | |
foo() { | |
echo "$*" | |
eval "$*" | |
} | |
# echo command & execute without escape. | |
foo2() { | |
echo "$*" | |
"$@" | |
} | |
libs="-L/usr/local/lib -L/lib/x86_64-linux-gnu/" | |
# Just want to add `foo` function but quote in parameter will disapper. Need escape quote like \"\" | |
# ただ foo 関数を頭につけてあげたいが、パラメーターの "" が消えてしまうので \"\" でエスケープが必要 | |
# CLIBS is '-L/usr/local/lib -L/lib/x86_64-linux-gnu/' | |
echo "* echo ..." | |
make foo CLIBS="$libs" | |
# 🚀 GOOD. | |
# make foo CLIBS="-L/usr/local/lib -L/lib/x86_64-linux-gnu/" | |
# CLIBS is '-L/usr/local/lib -L/lib/x86_64-linux-gnu/' | |
echo "* run \\ ..." | |
foo make foo CLIBS=\"$libs\" | |
# 😢 BAD. | |
# make foo CLIBS=-L/usr/local/lib -L/lib/x86_64-linux-gnu/ | |
# make: invalid option -- '/' | |
# Usage: make [options] [target] ... | |
# foo make foo CLIBS="$libs" # require escape "libs" -> \"$libs\" | |
# 🤔 SOSO. missing quote from `echo` message. | |
# make foo CLIBS=-L/usr/local/lib -L/lib/x86_64-linux-gnu/ | |
# CLIBS is '-L/usr/local/lib -L/lib/x86_64-linux-gnu/' | |
echo "* run ..." | |
foo2 make foo CLIBS="$libs" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment