Kaunteya
Kaunteya

Reputation: 3090

Space separated arguments in bash

#!/bin/bash  

ret=`zenity --entry `  

zenity --entry --text=$ret  

Here second instruction only prints first word of the string. How do I take string which can contain white spaces ??

Upvotes: 0

Views: 2048

Answers (1)

paxdiablo
paxdiablo

Reputation: 882136

With this:

zenity --entry "--text=$ret"

That should present the entire --text=thing with spaces in it as a single argument.

Of course, your zenity executable must still be able to handle arguments with spaces in them but that would be a different issue.

By way of example, see the following script executable:

#!/bin/bash
echo "[$1]" "[$2]"

When you run it without and with quotes, you get the following results:

pax> ./testprog.sh two args
[two] [args]

pax> ./testprog.sh "one arg"
[one arg] []

Upvotes: 2

Related Questions