deno
deno copied to clipboard
Deno task doesn't accept {}
Trying to run a task with { or } fails:
// deno.json
{
"tasks": {
"slash": "echo {}",
}
}
$ deno task slash
Task slash echo {}
error: Error parsing script 'slash'.
Caused by:
Unexpected character.
{}
~
It doesn't work no matter how hard I escape the braces.
The { and } are used in the bash function find -exec {} \; syntax.
As a workaround, you can put the string in quotes:
{
"tasks": {
"slash": "echo '{}'",
}
}
when I do that, find can no longer work because the -exec parameter
needs to end with exactly {};
On Fri, 13 Oct 2023, 02:38 David Sherret, @.***> wrote:
As a workaround, you can put the string in quotes:
{ "tasks": { "slash": "echo '{}'", } }
— Reply to this email directly, view it on GitHub https://github.com/denoland/deno/issues/20893#issuecomment-1760590526, or unsubscribe https://github.com/notifications/unsubscribe-auth/AJB5FCP4UCAETPUJ56ORDXLX7CEPLANCNFSM6AAAAAA556VSQU . You are receiving this because you authored the thread.Message ID: @.***>
@vixalien can you show the actual example that's failing?
Without single quotes:
$ deno task find
Task find find -regex '.*\.[tj]sx?' -exec grep -i class {} \;
error: Error parsing script 'find'.
Caused by:
Unexpected character.
{} \;
~
With single quotes:
$ deno task find
Task find find -regex '.*\.[tj]sx?' -exec grep -i class '{}' \;
/usr/bin/find: missing argument to `-exec'
$
@vixalien , you can do the classic hacky nested shell. This worked for me.
{
"tasks": {
"find": "sh -c \"find -regex '.*\\.[tj]sx?' -exec grep -i class {} \\;\""
}
}
It seems also the escaping of ; does not work. The following does though:
{
"tasks": {
"find": "find -regex '.*\\.[tj]sx?' -exec grep -i class '{}' ';'"
}
}
@dsherret , I don't know why deno tasks is choking on {} in the first place. If you don't think it's a bug and just an escaping issue, can you lightly explain and I can add something to the deno task documentation?
It is a bug.
yes I think it's a bug. I'm not sure why it would not accept {} in the first place too.
Getting that issue as well:
"dc:clean": "docker ps -a -q --filter=\"name=app\" | xargs -I {} docker stop {} && docker ps -a -q --filter=\"name=app\" | xargs -I {} docker rm -f {}",
error: Error parsing script 'dc:clean'.
Caused by:
Unexpected character.
{} docker stop {} && docker ps -a -q --filter="name=app" | x
~
Single quote '{}' does not help.