1

I read this post: https://superuser.com/questions/304807/brace-expansion-run-several-commands-instead-of-expanding-on-one-line and tried its eval echo way of expansion. Why are the two commands below different?


Command 1:

$ eval echo\ {a,b,c}\;

Result 1:

a
b
c

Command 2:

$ eval echo\ {a,b,c} \;

Result 2:

a echo b echo c
0

1 Answer 1

5

The eval is just confusing things, so get rid of it:

$ echo echo\ {a,b,c}\;
echo a; echo b; echo c;
$ echo echo\ {a,b,c} \;
echo a echo b echo c ;

That should make it obvious what's happening. In the first case, eval executes three different echo commands. In the second, it only evaluates one command that takes the string 'a echo b echo c' as an argument.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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