From c5a6f829a9ebe8fa51e23d85aa00bf937500f5c7 Mon Sep 17 00:00:00 2001 From: Maxim Likhachev Date: Wed, 13 Nov 2019 22:04:39 +0300 Subject: [PATCH] viper: show output only if exit code is 0 --- viper | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/viper b/viper index 3333a3f..96bbf26 100755 --- a/viper +++ b/viper @@ -1,10 +1,12 @@ #!/bin/bash -# (c) https://stackoverflow.com/questions/10686183/pipe-vim-buffer-to-stdout/10686830#10686830 - TMPFILE=$(mktemp /tmp/viper.XXXXXXXX) cat > "$TMPFILE" $EDITOR "$@" "$TMPFILE" < /dev/tty > /dev/tty -cat "$TMPFILE" + +if [ "$?" -eq 0 ]; then + cat "$TMPFILE" +fi + \rm -f "$TMPFILE"