Skip to content
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

string interpolation in aliases #1135

Closed
mpeck opened this issue Nov 7, 2016 · 0 comments · Fixed by operable/piper#36
Closed

string interpolation in aliases #1135

mpeck opened this issue Nov 7, 2016 · 0 comments · Fixed by operable/piper#36
Assignees
Milestone

Comments

@mpeck
Copy link
Contributor

mpeck commented Nov 7, 2016

Before we added string interpolation we could do things like this:

alias create my-alias "echo foobar | echo $body[0]"

The variable would then be substituted as normal when the alias was executed.

> my-alias
> foobar

Now when we try to do something like the above the parser returns an error:
Note: error responses are returned as standard command errors. I've just removed everything except the actual error message for brevity.

> alias create my-alias "echo foobar | echo $body[0]"
> illegal characters "$b"

Using the string interpolation syntax doesn't work because the variables are replaced when trying to create the alias, resulting in a "can't find the variable" error.

> alias create my-alias "echo foobar | echo ${body[0]}"
> I can't find the variable '$body'.

Using a slash before the variable allows for successful creation of the alias, but the slash is then displayed in the output when the alias is executed:

> alias create my-alias "echo foobar | echo \$body[0]"
> Alias 'user:my-alias' has been created
> my-alias
> \ foobar
@mpeck mpeck added the bug label Nov 7, 2016
@kevsmith kevsmith self-assigned this Nov 7, 2016
@kevsmith kevsmith removed the review label Nov 7, 2016
@mpeck mpeck added this to the Cog 0.17 milestone Nov 7, 2016
@kevsmith kevsmith modified the milestones: Cog 0.17, Cog 0.16.1 Nov 7, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants