:: Re: [DNG] [OT] bash / quote weirdne…
Startseite
Nachricht löschen
Nachricht beantworten
Autor: william moss
Datum:  
To: dng
Betreff: Re: [DNG] [OT] bash / quote weirdness
On 1/12/22 04:39, Alessandro Vesely via Dng wrote:
> On Wed 12/Jan/2022 01:27:45 +0100 Florian Zieboll via Dng wrote:
>> On Tue, 11 Jan 2022 18:52:10 -0500
>> william moss <bill.m.moss@???> wrote:
>>
>>> Bash is taking the string in the double quotes as a single command;
>>> this is well documented. If either the command or parameters have
>>> spaces, you will have to use eval. Check the bash man page for
>>> details.
>>>
>>> This will also usually work
>>>     X=$( "command and such" )
>>> due to the execute block.
>>
>> I am replying to the list to share the valid (tested) alternative.
>> Thanks a lot!
>
>
> Bash still considers a quoted command as such, for example:
>
> ale@pcale:~/tmp$ X=$("echo foo")
> bash: echo foo: command not found
>
>
> Best
> Ale


X=$( eval "echo foo" )

echo "$X"

foo

-- 
William (Bill) Moss
billmoss@???
NY (USA)
     Those who will not reason, are bigots,
     those who cannot, are fools,
     and those who dare not, are slaves.
Lord Byron


     Justice will not be served until those who are
     unaffected are as outraged as those who are.
Benjamin Franklin


     When the people fear the government there is
     tyranny, when the government fears the people
     there is liberty.
John Basil Barnhill