Zitieren des Fehlerargumentefehlers
Frage
Wie sollte repariert werden? command
Variable, um ein korrektes Verhalten zu erhalten?
#!/bin/bash
function f ( )
{
echo "$2"
}
command="f --option=\"One Two Three\" --another_option=\"Four Five Six\""
$command
f --option="One Two Three" --another_option="Four Five Six"
Das erste Anruf ist falsch, zweitens - richtig
$> ./test.sh
Two
--another_option=Four Five Six
Lösung
TL; DR: Verwenden Sie ein Array.
command=(f --option="One Two Three" --another_option="Four Five Six")
"${command[@]}"
Andere Tipps
Sie können die Variable nicht beheben. Doch kannst du:
eval $command
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow