I defined a function in my .bashrc that allows me to open e.g. pdf files from bash by running copen myfile.pdf:function copen {    if [[ $# -eq 1 ]] ; then        xdg-open $1 > /dev/null 2>&1 & disown        return 1    fi}By running this command, I execute e.g. Okular in the background, redirect STDOUT and STDERR to /dev/null and disown it from bash. However, after running copen myfile.pdf I still get output printed to bash (QSqlQuery::exec: database not open multiple times) and I don't understand why. How do I suppress that kind of output?Note that the problem persists when changing the code to nohup xdg-open $1 > /dev/null 2>&1 &.
Disowned command with redirected STDOUT/STDERR still sending output to shell
bash;io redirection;bashrc;nohup;disown
Try this approach:#!/usr/bin/bashcopen() {    (($# == 1)) && xdg-open $1 &>/dev/null & disown}copen $1Run the script as follows:  ./myscript SomePDFfile.pdfThe &>/dev/null is a shorthand for >/dev/null 2>&1 added in bash >4.The copen function needs a parameter. 