Snippets and Shell $vars


#1

I do a lot of shell scripting and I am attempting to populate my snippets.

While I have simple snippets working I have found that I cannot populate my snippets with $N as these are used to define snippet behaviour. Can someone please tell me how I can delimit my own shell vars so they are not stripped from the snippet.

EG:

.source.shell':
'shell.alert':
'prefix': 'shellalert'
'body': 'alert() {\n\t# Usage: alert <$?> <object>\n\tif [ "$1" -ne 0 ]'

The above snippet is for a simple alert function. The $1 in the above is stripped when invoked.

Thanks in advance.


#2

I haven’t tried this, but have you tried prefixing the $ with a backslash or other common escape character?


#3

I have and it did not work unfortunately.

 "\$1" does not delimit the $. 

Note the:

Usage: alert <$?>

Displays just fine with no delimiters so its the combination of $ and int that seems to be causing the issue.