Can anyone explain to me why this doesn't work?
Code:
#!/bin/sh
#PS4=">>>> "
#set -xv
var="'This is label'"
ls ${var}
[~/]% ./test.sh
ls: cannot access 'This: No such file or directory
ls: cannot access is: No such file or directory
ls: cannot access label': No such file or directory
From commandline (/bin/sh):
Code:
sh-4.2$ ls 'This is label'
This is label
I'm confused ...
... Turning on
set -xv only served to increase my confusion
Code:
[~]% ./test.sh
var="'This is label'"
>>>> var=''\''This is label'\'''
ls ${var}
>>>> ls ''\''This' is 'label'\'''
ls: cannot access 'This: No such file or directory
ls: cannot access is: No such file or directory
ls: cannot access label': No such file or directory
Exit 2
Where did all those quotes come from
?
The larger picture:
I want to build a variable with arguments for (c)dialog, i.e.:
# dialog --menu 'Hello world' 10 40 9 "This is Label" "This is text "
If I put
"This is label" "This is text" inside a variable it doesn't work ...
(Of course, the real script has many more menu entries...
)