In shake-build, how to run a command with a pipe in it?

65 views Asked by At

I can't seem to get the following to work in shake:

cmd_ (AddEnv "PGPASSWORD" "REDACTED") "bzcat /tmp/db.sql.bz2 | psql -U pguser -h localhost dbname"
2

There are 2 answers

0
Neil Mitchell On

In Shake, the cmd function and variants spawn processes directly by default. The pipe syntax is only available as part of the OS's shell functionality. To ask Shake to spawn things using the shell add the argument Shell.

0
Lemming On

It should work this way:

Stdout pipe <- cmd (AddEnv "PGPASSWORD" "REDACTED") "bzcat /tmp/db.sql.bz2"
cmd_ "psql -U pguser -h localhost dbname" (Stdin pipe)