GNU make用のMakefileを書こうとしています。私はこの問題はここにあるかを把握することはできません。私は文字列を定義しようとしていますが、X = "どちらか 'this' that '"でもGNU makeはそれを受け入れません。
foo := this|works
bar := "I lost my 'single quotes'"
baz := 'make|will|not|accept|this|with|the|single|quotes'
whatIWant := "A string with its 'single|quoted|regex|alternatives'"
this-almost-works: #But the single quotes are lost.
@printf '%s ' "$(whatIWant)"
this-fails-horribly:
@printf '$(whatIWant)'
私は
/bin/sh: 1: quoted: not found
/bin/sh: 1: /bin/sh: 1: regex: not foundalternatives": not found
blah blah Error 127
は、なぜそれがシェルでこの文字列の部分を実行しようとしている、次のエラーメッセージが表示されますか?
whatIWantの内容を正確に含むように変数を定義するにはどうすればよいですか?
パイプが '\'でエスケープされていますが、正しくパイプがメイクファイルの特殊文字であることがわかっている場合は – mascoj
Coolです。これは、エラーメッセージを回避するのに役立ちます。なぜfooが動作するのかはわかりませんが、bazは動作しません。私はまだそれらの単一引用符が必要です。何らかの理由で彼らは消える。 –
Makeは引用符を解釈せず、文字列内にあります。 '' '' @printf '%s' ""一重引用符| regex | alternatives "" "' ''で囲まれた文字列で、引用符で囲まれているので '' ' '' single | quoted | regex | alternatives'''''は引用符で囲まれた文字列であるため、引用符を失います。それは理にかなっていますか? – mascoj