I wrote a function in Bash to see man pages in Vim:
viman () { man "$@" | vim -R +":set ft=man" - ; }
This works fine, the only problem occurs if I pass a man page to it which doesn't exist. It prints that the man page doesn't exist but still opens vim with an empty buffer.
So, I changed the function to check the error code (which is 16 here) and exit if the page doesn't exist. The modified function looks somewhat like this:
viman () { man "$@" | [[ $? == 16 ]] && exit 1 | vim -R +":set ft=man" - ; }
But, now it doesn't do anything.
I just want to quit the program if the man page doesn't exist, otherwise open the man page with vim.