0
votes

I did this on top of my .bashrc

.bashrc

vm_name=$(curl http://artii.herokuapp.com/make?text=saml)
echo -e \"





$vm_name



\"

I got

\[\]                      _ 
                     | |
  ___  __ _ _ __ ___ | |
 / __|/ _ _ \| |
 \__ \ (_| | | | | | | |
 |___/\__,_|_| |_| |_|_|

                        \[\]

I got this error

-bash: command substitution: line 9: syntax error near unexpected token |' -bash: command substitution: line 9: | '_ '

Is there a way to bypass this error and force my echo to treat my banner as string ?

1
Why echo -e? You can just put curl -s http://artii.herokuapp.com/make?text=saml in your .bashrc - anubhava
Yeb, that solved the problem perfectly. I never use curl -s before. I guess that do the trick. - code8888
Why did you escape the quotes? - 123
Worked without -s in Debian just fine. - George Vasiliou

1 Answers

3
votes

While you have found a solution to your problem, it is worth explaining your problem. By escaping the double quotes, you prevent them from being parsed as syntactic quotes (they are interpreted as literal quotes).

Therefore, you are not echoing $vm_name preceded and followed by empty lines : you are actually echoing ", having empty command lines (doing nothing), and then trying to execute the content of vm_name expanded, subject to word splitting, and then seen as a command followed by arguments (which understandably fails).

The following would have worked :

vm_name=$(curl http://artii.herokuapp.com/make?text=saml)
echo -e "


$vm_name

"

Of course, just executing the curl command without capturing it in a variable is simpler.

Just remember escaped double quotes are not interpreted as string delimiters, they are literal double quotes.