Shell variables containing output redirects
Alexander Yerenkow
yerenkow at gmail.com
Thu Jun 20 14:57:43 UTC 2013
Hello all!
I have a problem with port JBoss72, which tries to behave as long-standing
port jboss5:
http://svnweb.freebsd.org/ports/head/java/jboss5/files/jboss5.in?revision=302141&view=markup
In rc run script there is such line:
%%APP_SHORTNAME%%_logging="${%%APP_SHORTNAME%%_logging:-">>
${%%APP_SHORTNAME%%_logdir}/stdout.log 2>>
${%%APP_SHORTNAME%%_logdir}/stderr.log"}"
Which provides way to overwrite default log location in /etc/rc.conf.
But this not working at all, all these redirects treated as simple
parameters for run script.
I made small test, to show my problem:
#!/bin/sh
logfile="supposed-to-be.log"
log=">> ${logfile}"
echo "a1" >> ${logfile}
echo "a2" ${log}
cmd="echo \"a3\" ${log}"
echo $cmd
$cmd
more ${logfile}
Here's execution output:
# ./t1.sh
a2 >> supposed-to-be.log
echo "a3" >> supposed-to-be.log
"a3" >> supposed-to-be.log
a1
1. My question is - Which are correct way to specify such redirects to be
overridden?
2. tomcat6.in, rubyrep.in, tclhttpd.in, geoserver.in, and many more rc
scripts from ports are using something like this:
log_args=">> ${tclhttpd_stdout_log} 2>> ${tclhttpd_stderr_log} "
and after that use $log_args.
Are they silently broken, or am I missing something?
3. Should I build up $cmd, and run
eval "$cmd" - would this be nice ro dirty hack?
Thanks!
--
Regards,
Alexander Yerenkow
More information about the freebsd-hackers
mailing list