I'm trying to make this quoting work, but no success :
export perl_script='$| = 1;s/\n/\r/g if $_ =~ /^AV:/;s/Saving state/\nSaving state/' mpv="command mpv" mpvOptions='--geometry 0%:100%' args=("$@") $ sh -c "$mpv $mpvOptions ${args[*]} 2>&1 | perl -p -e $perl_script | tee ~/mpv_all.log" syntax error at -e line 1, at EOF Execution of -e aborted due to compilation errors. sh: 1: =: not found sh: 1: s/n/r/g: not found sh: 1: s/Saving: not found So I tried this :
$ sh -c "$mpv $mpvOptions ${args[*]} 2>&1 | perl -p -e \"perl_script\" | tee ~/mpv_all.log" Unknown regexp modifier "/h" at -e line 1, at end of line Execution of -e aborted due to compilation errors. Quoting is such a pain in the neck.
sh -c "$mpv ${args[*]} 2>&1 | perl -p -e '$perl_script' | tee ~/mpv_all.log". Why does everything need to be insidesh -c?nohup sh -c ....