This question already has an answer here:

There's next code:

TITLE="Some value with spaces"
DIALOG="${DIALOG=dialog} --clear --no-tags --tab-correct --backtitle $TITLE "
$DIALOG --title "Some title --menu "Menu" 15 60 5 "1" "menu1" "2" "menu2"

When TITLE contains string with no spaces DIALOG works OK. With spaces - no correct substitution is done.

Tried to use variants like (with no luck):

TITLE='Some value with spaces'
TITLE="Some\ value\ with\ spaces"

How has correct substitution to be done?

marked as duplicate by Gilles bash Apr 1 '17 at 14:26

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • 1
    Use an array. See the answer here – ilkkachu Apr 1 '17 at 14:08

This code works OK:

TITLE="Some value with spaces"
OPTS=(--clear --no-tags --tab-correct --backtitle "$TITLE")
$DIALOG "${OPTS[@]}" --title "Some title" --menu "Menu" 15 60 5 "1" "menu1" "2" "menu2"

Thanks to ilkkachu

Not the answer you're looking for? Browse other questions tagged or ask your own question.