在Bash中,如何以下列方式扩展存储为“元组”的命令:
#!/bin/bash
CMD=/my/cmd
DEV=/dev/loop
for setting in "${CMD} option1 option2 ${DEV}","SETTING1: yes" \
"${CMD} option1 ${DEV}","SETTING2: 0x01" ; do
OLDIFS="${IFS}"
IFS=","
set -- $setting;
echo $1 and $2
#How do I expand this correctly to run the command stored in ${1}?
${1}
#... checking output using value stored in ${2}
IFS="${OLDIFS}"
fi
目前,shell会将$ {1}解释为以空格分隔的多个命令,所以我只得到一堆“没有这样的文件或目录”