Skip to content

snippets: allow escaped shell vars like ${\1:?foo} #23

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

AndrewDDavis
Copy link

The syntax for snippet placeholders is identical to some shell parameter expansions of the positional arguments in a script. If you want to put such shell expansions in a snippet, the snippet is mangled when it's inserted.

This PR fixes the problem by allowing shell snippets to have a syntax like ${\1:?message}, which doesn't match the pattern from snippet placeholders. After the code for identifying snippet placeholders is run, this call to gsub strips the backslash from the parameter expansion to produce the code that was actually intended.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant