octave-maintainers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: popen2 example gives no output


From: Stefan van der Walt
Subject: Re: popen2 example gives no output
Date: Sat, 24 Sep 2005 14:11:34 +0200
User-agent: Mutt/1.5.9i

On Fri, Sep 23, 2005 at 11:29:28PM -0400, John W. Eaton wrote:
> Here is the perl "script" that I ended up with in src/Makefile ($
> symbols are doubled because this comes out of a Makefile):
> 
>   $(PERL) -e 'foreach $$key (keys(%!)) {
>     $$x .= "#if defined ($$key)\n    { \"$$key\", $$key, },\n#endif\n";
>   }; while (<>) {
>     s/^ address@hidden@/$$x/;
>     print;
>   }'
> 
> What would the same be in Python?  Can it easily go in a Makefile as a
> one-liner?  If so, then we can use either Perl or Python, depending on
> which is available.

Maybe something like

${PYTHON} -c '
from errno import errorcode
from string import Template, join
from sys import stdin

t = Template("#if defned (\$e)\n{ \"$e\", $e, },\n#endif\n")
errstr = join([t.substitute(e=errorcode[i]) for i in errorcode.keys()])

for l in stdin:
    print l.replace("@SYSDEP_ERRNO_LIST@", errstr),
'

Regards
Stéfan



reply via email to

[Prev in Thread] Current Thread [Next in Thread]