node-gh / gh

(DEPRECATED) GitHub CLI made with NodeJS. Use the official https://cli.github.com/ instead.
http://nodegh.io
Other
1.71k stars 217 forks source link

Can't use backticks in comment strings #464

Closed meetmangukiya closed 7 years ago

meetmangukiya commented 7 years ago

I tried following command:

gh is -n 1 -c "Instead of parsing whole hmtl by regex, we must use modules like `lxml`"

I expected it to comment the lxml in a monospaced font. The comment can be found here https://github.com/meetmangukiya/frisbee/issues/1#issuecomment-269066776

sholladay commented 7 years ago

This is user error, sorry to say. And it has to do with the shell rather than gh. You are using double quotes for the argument. The shell evaluates this, unlike single quotes. And backticks, as far as the shell is concerned, means to execute a command in a subshell.

To see what I mean, try running:

echo "foo `ls`"

I'll give you a hint: it's probably going to print more than a few characters.

I'm actually surprised you didn't see:

-bash: lxml: command not found

Maybe you just missed it?

The solution is to use single quotes.

gh is -n 1 -c 'Instead of parsing whole hmtl by regex, we must use modules like `lxml`'

When dealing with the shell, it's always best to use single quotes unless you know you need something else. It will lead to less surprises.

henvic commented 7 years ago

Nice catch, @sholladay.