user3310334
user3310334

Reputation:

GNU parallel with Perl expression; zsh: parse error near `}'

Trying to run this example command (from the man page):

seq 10 | parallel echo {} + 1 is {= '$_++' =}

I get the error

zsh: parse error near `}'

How can I fix this and use {=perl expression=} replacement strings in my parallel commands?

I'm in iTerm 2 on macOS, using zsh.

Upvotes: 1

Views: 580

Answers (2)

user3310334
user3310334

Reputation:

(Thanks to @MarkSetchell)

This worked perfectly for me:

seq 10 | parallel --parens ,,,, echo {} + 1 is ,, '$_++' ,,

Setting --parens to ,,,, and then quoting the perl expression as ,,perl expression,,.

Upvotes: 1

chepner
chepner

Reputation: 531075

As with any command, quote whatever zsh will try to interpret itself if left unquoted.

seq 10 | parallel 'echo {} + 1 is {= $_++ =}'

In this case, parallel is just going to join the various elements into a single string, then subject it to its own parsing, before passing the result to a shell; you may as well just pass a single string to start.

Upvotes: 4

Related Questions