I have this command where I want to filter make
output:
cd /app && make && sudo nginx -g 'daemon off;'
What is the correct way to insert make | pv -q -L 100
here?
I have this command where I want to filter make
output:
cd /app && make && sudo nginx -g 'daemon off;'
What is the correct way to insert make | pv -q -L 100
here?
The problem is that you'll be checking the exit status of pv
. With POSIX sh
syntax, you could do:
cd /app && ((make 3>&- && exec sudo nginx -g 'daemon off;' >&3 3>&-) | pv -qL 100) 3>&1
Or with ksh
/bash
/zsh
:
(set -o pipefail
cd /app && make | pv -qL 100 && sudo nginx -g 'daemon off;')
Or with zsh
:
cd /app && make | pv -qL 100 && ((!pipestatus[1])) && sudo nginx -g 'daemon off;'
Or with bash
:
cd /app && make | pv -qL 100 && ((!PIPESTATUS[0])) && sudo nginx -g 'daemon off;'
[STDERR] /bin/sh: 1: !PIPESTATUS[0]: not found
. I run this command with CMD from Dockerfile.
– anatoly techtonik
Feb 26 '15 at 12:47
PIPESTATUS
is for bash
. For sh
, use the first one.
– Stéphane Chazelas
Feb 26 '15 at 12:54
CMD bash -c "(set -o pipefail; cd /app && make | pv -q -L 150 && sudo nginx -g 'daemon off;')"
– anatoly techtonik
Feb 26 '15 at 13:21