Eval выполняет команду, но замена команды прерывает ее ⇐ Linux
-
Гость
Eval выполняет команду, но замена команды прерывает ее
I have the following code
#!/bin/sh echo "intented command:" jq -n --argjson bar '{"test":"asdf"}' '$bar | .test' foo="{\"test\":\"asdf\"}" command="jq -n --argjson bar '$foo' '\$bar | .test'" echo "Built command:" echo $command echo "Command execution with eval:" eval $command echo "Command execution with command substitution:" $($command) The first command works just fine and shows that the usecase is executable, also the outputed command by echo is exactly as in the original command in line 3, so I understand the escaping is working as intended.
eval evaluates the command stored in command just fine, but $($command) fails with the error message
jq: invalid JSON text passed to --argjson Use jq --help for help with command-line options, or see the jq manpage, or online docs at https://stedolan.github.io/jq I would therefore expect that the escaping is somehow changes in $($command) but I could not identify why. Can anybody please explain?
Источник: https://stackoverflow.com/questions/781 ... -breaks-it
I have the following code
#!/bin/sh echo "intented command:" jq -n --argjson bar '{"test":"asdf"}' '$bar | .test' foo="{\"test\":\"asdf\"}" command="jq -n --argjson bar '$foo' '\$bar | .test'" echo "Built command:" echo $command echo "Command execution with eval:" eval $command echo "Command execution with command substitution:" $($command) The first command works just fine and shows that the usecase is executable, also the outputed command by echo is exactly as in the original command in line 3, so I understand the escaping is working as intended.
eval evaluates the command stored in command just fine, but $($command) fails with the error message
jq: invalid JSON text passed to --argjson Use jq --help for help with command-line options, or see the jq manpage, or online docs at https://stedolan.github.io/jq I would therefore expect that the escaping is somehow changes in $($command) but I could not identify why. Can anybody please explain?
Источник: https://stackoverflow.com/questions/781 ... -breaks-it
Мобильная версия