www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 7283] New: Add error info to failed shell call

reply d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=7283

           Summary: Add error info to failed shell call
           Product: D
           Version: D2
          Platform: Other
        OS/Version: Windows
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Phobos
        AssignedTo: nobody puremagic.com
        ReportedBy: andrej.mitrovich gmail.com



16:40:32 PST ---
std.process.shell implements the system call with errnoEnforce, returning no
useful information on what went wrong. Here's what a typical call produces:

import std.exception;
import std.process;
import std.string;

void main()
{
    string cmd = "dmd -c blasudfasudfa.d";
    shell(cmd);
}

std.exception.ErrnoException std\process.d(364):  (No error)
----------------
D:\dev\code\d_code\test.d(8): D main
----------------

I hate that confusing "No error" as well. I suggest we reimplement shell() so
it does the following:

import std.exception;
import std.process;
import std.string;

void main()
{
    string cmd = "dmd -c blasudfasudfa.d";
    string filename = "blabiudasf";
    auto result = system(cmd ~ "> " ~ filename);
    enforce(result == 0, format(`system("%s") returned %s`, cmd, result));
}

Result:
object.Exception test.d(12): system("dmd -c blasudfasudfa.d") returned 1

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jan 12 2012
parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=7283


Andrej Mitrovic <andrej.mitrovich gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
           Platform|Other                       |All
         Resolution|                            |WORKSFORME
         OS/Version|Windows                     |All



14:37:17 PDT ---
In 2.063.2 this is now:

Error: cannot read file blasudfasudfa.d
std.exception.ErrnoException std\process.d(3169):  (No error)

I think that's good enough, the error is now displayed above. Although I'm not
sure whether that's Phobos outputting this or my console.

If someone still wants to improve this, reopen the issue.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Sep 17 2013