受け取ったものを出力して終了する単純なスクリプトがあります。
IFS="|${IFS}";
echo "$# parameters";
echo Using '$*';
for p in $*;
do
echo "[$p]";
done;
echo Using '"$*"';
for p in "$*";
do
echo "[$p]";
done;
echo Using '$@';
for p in $@;
do
echo "[$p]";
done;
echo Using '"$@"';
for p in "$@";
do
echo "[$p]";
done
実行すると:./echoparams This is a "test target"
出力されます:
4 parameters
Using $*
[This]
[is]
[a]
[Test]
[target]
Using "$*"
[This|is|a|Test target]
Using $@
[This]
[is]
[a]
[Test]
[target]
Using "$@"
[This]
[is]
[a]
[Test target]
問題:
これをスクリプトに渡す外部プログラム(変更できない)がありますが、実行すると次のように出力されます。
1 parameters
Using $*
[This]
[is]
[a]
["test]
[target"]
Using "$*"
[This is a "test target"]
Using $@
[This]
[is]
[a]
["test]
[target"]
Using "$@"
[This is a "test target"]
"This is a \"test target\""
実際にスクリプト に渡されているという予感があります。この「1つのパラメーター」を「複数のパラメーター」にするにはどうすればよいですか?