I have defined a test alias as:
alias testalias='python3 -c "f = open(\"/tmp/testopenfile\", \"w+\"); f.write(\"hi\n\")"'
It works fine when I run it directly through terminal. I can cat /tmp/testopenfile normally. I have also defined a helper function to background and mute error and output of programs. I thought of using this function with some aliases that takes long time or that are on while loop (not this one as its just example). It is defined like this:
detach is a function
detach ()
{
$1 > /dev/null 2> /dev/null &
}
I am using bash, and I tried to combine those two things. When I tried detach testalias
, it doesn't seem to work (/tmp/testopenfile doesn't seem to be created). It looks like testalias is directly is passed and not evaluated. What is the hack for making this evaluate before passing.
Also, this code creates the file:
python3 -c "f = open(\"/tmp/testopenfile\", \"w+\"); f.write(\"hi\n\")" 1>/dev/null 2>/dev/null &