Re: std.process.execute without capturing stderr?

2018-09-21 Thread Adam D. Ruppe via Digitalmars-d-learn

On Friday, 21 September 2018 at 06:08:39 UTC, berni wrote:
Sorry, I made a mistake while testing and after I found out, 
that it was not available in the documentation at dpldocs.info 
I concluded, that it must be a really new feature. But now it 
seems to me, that dpldocs is outdated a little bit, isn't it?


Oh yeah, I haven't updated Phobos on it for a while, my attention 
most this year has been the dub thingy. Just did though.




Re: std.process.execute without capturing stderr?

2018-09-21 Thread berni via Digitalmars-d-learn
On Thursday, 20 September 2018 at 14:10:44 UTC, Steven 
Schveighoffer wrote:

Hm... 2.079.0 had it:


Sorry, I made a mistake while testing and after I found out, that 
it was not available in the documentation at dpldocs.info I 
concluded, that it must be a really new feature. But now it seems 
to me, that dpldocs is outdated a little bit, isn't it?


Meanwhile I've got the latest version of dmd and made it working.


Re: std.process.execute without capturing stderr?

2018-09-20 Thread Steven Schveighoffer via Digitalmars-d-learn

On 9/20/18 4:02 AM, berni wrote:

On Thursday, 20 September 2018 at 07:36:06 UTC, Paul Backus wrote:

Looks like `Config.stderrPassThrough` [1] should do what you want:

    const result = execute(args[1..$], null, Config.stdErrPassThrough);

[1] https://dlang.org/phobos/std_process.html#.Config.stderrPassThrough


In theory that looks good. Unfortunatley it's a relativly young feature 
which my compilers don't know about yet (dmd 2.079 and ldc based on an 
even older version of dmd). So in practice I'll probably have to wait 
until the next release cycle of debian in spring 2019... (maybe for the 
time being I'll update dmd and use dmd for this small part instead of 
ldc, but I yet don't know how to tell CMake to use dmd for this one 
file... But I'll probably figure this out.)




Hm... 2.079.0 had it:

https://docarchives.dlang.io/v2.079.0/phobos/std_process.html#.Config.stderrPassThrough

I don't know what your "older version of dmd" was, but the earliest I 
can see it is 2.077.0.


Indeed, it was fixed in 2.077 (look for Bugzilla 17844 here: 
https://dlang.org/changelog/2.077.0.html)


-Steve


Re: std.process.execute without capturing stderr?

2018-09-20 Thread berni via Digitalmars-d-learn

On Thursday, 20 September 2018 at 07:36:06 UTC, Paul Backus wrote:
Looks like `Config.stderrPassThrough` [1] should do what you 
want:


const result = execute(args[1..$], null, 
Config.stdErrPassThrough);


[1] 
https://dlang.org/phobos/std_process.html#.Config.stderrPassThrough


In theory that looks good. Unfortunatley it's a relativly young 
feature which my compilers don't know about yet (dmd 2.079 and 
ldc based on an even older version of dmd). So in practice I'll 
probably have to wait until the next release cycle of debian in 
spring 2019... (maybe for the time being I'll update dmd and use 
dmd for this small part instead of ldc, but I yet don't know how 
to tell CMake to use dmd for this one file... But I'll probably 
figure this out.)




Re: std.process.execute without capturing stderr?

2018-09-20 Thread Paul Backus via Digitalmars-d-learn

On Thursday, 20 September 2018 at 07:24:52 UTC, berni wrote:
I need to execute a program and capture stdout, which I hoped 
std.process.execute would do. But unfortunatly this command 
also captures stderr, which I need to be ignored. When looking 
at the implementation of std.process.execute I see, that I can 
probably do this by removing "Redirect.stderrToStdout" in the 
function executeImpl. But for that I have to copy lots of 
functions from phobos in my own code. Is there an easier way to 
do that?


[...]

Here my complete program:


import std.process;
import std.stdio;
import std.array;

int main(string[] args)
{
const result = execute(args[1..$]);
writeln(result[1].replace("\\","").replace(" ","\\s"));
return result[0];
}


Looks like `Config.stderrPassThrough` [1] should do what you want:

const result = execute(args[1..$], null, 
Config.stdErrPassThrough);


[1] 
https://dlang.org/phobos/std_process.html#.Config.stderrPassThrough


std.process.execute without capturing stderr?

2018-09-20 Thread berni via Digitalmars-d-learn
I need to execute a program and capture stdout, which I hoped 
std.process.execute would do. But unfortunatly this command also 
captures stderr, which I need to be ignored. When looking at the 
implementation of std.process.execute I see, that I can probably 
do this by removing "Redirect.stderrToStdout" in the function 
executeImpl. But for that I have to copy lots of functions from 
phobos in my own code. Is there an easier way to do that?


In case you wonder why I need this: I'm currently using a PHP 
frontend and a D backend. I'm calling the D routines with the PHP 
exec command which works fine, but unfortunately removes trailing 
whitespaces, that I need. Therefore I'd like to have a wrapper 
that replaces all whitespace by some escape sequences which than 
are restored in PHP. First I thought I can use sed for that, but 
unfortunately the return code gets lost here. I'm using stderr to 
show some progress information, which should be shown 
immediately. (I've you've got other ideas how to get arround this 
design flaw (as I see it) in php exec, I'd be happy too.)


I don't want to touch the D backend - that's not the place, where 
the problem lies and when I decide to change the frontend I've to 
remember to change the backend too, which I don't like.


Here my complete program:


import std.process;
import std.stdio;
import std.array;

int main(string[] args)
{
const result = execute(args[1..$]);
writeln(result[1].replace("\\","").replace(" ","\\s"));
return result[0];
}