detix hat geschrieben:
Warum es nicht anders geht bleibt leider offen, dennoch gelöst!
Das Problem ist die Auswertung durch die Shell, weil die Single-Quotes innerhalb der Variable literal betrachtet werden und das Wordsplitting am Leerzeichen trennt. Ein vorgestelltes `set -x' zeigt das Problem (Paramter --fontname=... und die zusätzlich hinzugefügten Leerzeichen vor --undecorated) ganz gut:
Code: Alles auswählen
$ set -x
$ param="--no-buttons --undecorated --timeout=5 --fore=green --wrap --width=250 --justify=center --text-info --fontname='Monospace bold 12'"
## 56 : param='--no-buttons --undecorated --timeout=5 --fore=green --wrap --width=250 --justify=center --text-info --fontname='\''Monospace bold 12'\'''
$
$
$ yad "$param" <<< "So funktioniert mein Vorhaben perfekt"
## 57 : yad '--no-buttons --undecorated --timeout=5 --fore=green --wrap --width=250 --justify=center --text-info --fontname='\''Monospace bold 12'\'''
$ ## bzw.
$ yad $param <<< "So funktioniert mein Vorhaben perfekt"
## 58 : yad --no-buttons --undecorated --timeout=5 --fore=green --wrap --width=250 --justify=center --text-info '--fontname='\''Monospace' bold '12'\'''
$
Ungehen könnte man das (neben dem Array) mit eval. Damit wird die Kommandozeile zweimal von der Shell gelesen, beim zweiten Mal mit den ausgewerteten Argumenten des ersten Mals:
Code: Alles auswählen
$ eval yad "$param" <<< "So funktioniert mein Vorhaben perfekt"
## 59 : eval yad '--no-buttons --undecorated --timeout=5 --fore=green --wrap --width=250 --justify=center --text-info --fontname='\''Monospace bold 12'\'''
## 59 : yad --no-buttons --undecorated --timeout=5 --fore=green --wrap --width=250 --justify=center --text-info '--fontname=Monospace bold 12'
$
Wobei eval aber auch Probleme sicherheitstechnischer Art machen kann.
Ein einfaches Beispiel, was das Problem ebenfalls zeigt, aber lesbar ist:
Code: Alles auswählen
$ touch "file 1"
## 31 : touch 'file 1'
$ touch "file 2"
## 32 : touch 'file 2'
$ files="'file 1' 'file 2'"
## 33 : files=''\''file 1'\'' '\''file 2'\'''
$ ls $files
## 34 : ls ''\''file' '1'\''' ''\''file' '2'\'''
ls: cannot access "'file": No such file or directory
ls: cannot access "1'": No such file or directory
ls: cannot access "'file": No such file or directory
ls: cannot access "2'": No such file or directory
$ ls "$files"
## 35 : ls ''\''file 1'\'' '\''file 2'\'''
ls: cannot access "'file 1' 'file 2'": No such file or directory
$ eval ls "$files"
## 36 : eval ls ''\''file 1'\'' '\''file 2'\'''
## 36 : ls 'file 1' 'file 2'
'file 1' 'file 2'
$