I want to execute some code before execution(redirect stderr to stdout).
perl -e "BEGIN {open STDERR, '>&STDOUT'}" perl.pl
But when there is -e, no file will be executed. I know $Config{sitelib}/sitecustomize.pl
can pre-execute some code, and -f option can disable it. But this way is inflexible. In most cases, I do not need to add extra code. I don't want to add -f every time.
I cannot use shell to redirect. I want to set org-babel-perl-command
in emacs org mode so that stdout and stderr can be printed in the same way, instead of opening another window to print stderr. org-babel-perl-command
should be like perl
.
For example, org-babel-python-command
can be set to python -i -c "import sys; sys.stderr = sys.stdout"
.
CodePudding user response:
perl -e'
open( STDERR, ">&STDOUT" );
do( shift( @ARGV ) );
' perl.pl
(Error handling needed.)
For the case in question, the following would suffice:
perl perl.pl 2>&1
Maybe even
./perl.pl 2>&1
CodePudding user response:
You could just make a wrapper for perl. For example:
#!/bin/bash
exec perl "$@" 2>&1
Then make it executable and use instead of perl in your org-babel-perl-command
. Ensure it can be found in your PATH
or use full location.