How to implement 'set -o pipefail' in a POSIX way - almost done, expert help needed

后端 未结 4 655
故里飘歌
故里飘歌 2021-02-14 23:02

I have to implement the BASH set -o pipefail option in a POSIX way so that it works on various LINUX/UNIX flavors. To explain a bit, this option enables the user to

4条回答
  •  说谎
    说谎 (楼主)
    2021-02-14 23:29

    Am I missing something?

    my-script.sh

    #!/bin/sh
    
    set -e
    
    cat app.log | grep 'ERROR' 
    
    printf 'It will never print this.\n'
    
    $ ./my-script.sh
    cat: app.log: No such file or directory
    

提交回复
热议问题