I have a shell script with the following contents. I call it with ./script.sh. Echo successfully runs, but not when I try to save its output to a variable. The same is true for all commands I've tested so far; ls, pwd, node, etc…
#!/bin/zsh
echo foo
# foo
output=$("echo foo")
# command not found: echo foo
How come?
EDIT: Fix: the last echo is inside a string!



echo foolike:output=$('echo foo'). Or if I escape the space likeoutput=$(echo\ foo)."echo foo"would result in a similar error; what's your goal?