$ bash -version
GNU bash, version 4.3.11(1)-release (x86_64-pc-linux-gnu)
Run Code Online (Sandbox Code Playgroud)
考虑以下 shell 脚本:
#!/bin/bash
declare -A PROVS=( ["NL"]=10 ["PE"]=11 ["NS"]=12 ["NB"]=13 ["QC"]=24 ["ON"]=35 ["MB"]=46 ["SK"]=47 ["AB"]=48 ["BC"]=59 ["YK"]=60 ["NT"]=61 ["NU"]=62 )
for key in "${!PROVS[@]}" ; do \
touch "foo_${key}_${PROVS[${key}]}" ; \
done
Run Code Online (Sandbox Code Playgroud)
我正在尝试在 Makefile 中执行等效操作:
SHELL := /bin/bash
.PHONY: foo
foo:
declare -A PROVS=( ["NL"]=10 ["PE"]=11 ["NS"]=12 ["NB"]=13 ["QC"]=24 ["ON"]=35 ["MB"]=46 ["SK"]=47 ["AB"]=48 ["BC"]=59 ["YK"]=60 ["NT"]=61 ["NU"]=62 )
for key in "$${!PROVS[@]}" ; do \
touch "foo_$${key}_$${PROVS[$${key}]}" ; \
done
Run Code Online (Sandbox Code Playgroud)
我 …