Home

lprun6 not setting %errorlevel% on unhandled exception like linqpad5 lprun?

I know this had come up during linqpad5 in this thread but this seems to be a different issue AFAICT.

As with the previous thread, calling Environment.Exit(1); is a viable workaround but I wanted to understand if I was doing something wrong here or if it's an intentional change in linqpad6 behavior or just a regression.

lprun is linqpad5 Version=5.40.00(AnyCPU)
lprun6 is linqpad6 Version=6.7.5

C:\temp>type throw.linq
void Main()
{
    throw new Exception("foo");
}
C:\temp>lprun -lang=p throw.linq
Exception: foo
   at UserQuery.Main() in C:\temp\throw.linq:line 3
   at LINQPad.ExecutionModel.ClrQueryRunner.Run()
   at LINQPad.ExecutionModel.Server.RunQuery(QueryRunner runner)

C:\temp>echo %errorlevel%
1

C:\temp>lprun6 -lang=p throw.linq
Exception: foo
   at UserQuery.Main() in C:\Users\james.manning\AppData\Local\Temp\LINQPad6\_gfupjvto\ydhxbq\LINQPadQuery:line 3
   at LINQPad.ExecutionModel.ClrQueryRunner.Run()
   at LINQPad.ExecutionModel.Server.RunQuery(QueryRunner runner)

C:\temp>echo %errorlevel%
0

Comments

  • There seems to be a separate but potentially related issue with int-returning Main? lprun6 prints out the return value instead of changing the exit code?

    C:\temp>type ret1.linq
    int Main()
    {
        return 1;
    }
    C:\temp>lprun -lang=p ret1.linq
    
    C:\temp>echo %errorlevel%
    1
    
    C:\temp>lprun6 -lang=p ret1.linq
    1
    
    C:\temp>echo %errorlevel%
    0
    
  • Both of these issues should have been fixed in the last beta - let me know.

  • edited April 28

    @JoeAlbahari might be PEBCAK but AFAICT the exit code still isn't getting set correctly? In the case of int Main, it's not printing the returned value any longer, so that's good. I just downloaded the beta about an hour ago.

    C:\temp>lprun6|findstr Version
    Version=6.8.2
    
    C:\temp>lprun6 -lang=p throw.linq
    Exception: foo
       at UserQuery.Main() in C:\Users\james.manning\AppData\Local\Temp\LINQPad6\_dilhlbmd\wcjijc\LINQPadQuery:line 3
       at LINQPad.ExecutionModel.ClrQueryRunner.Run()
       at LINQPad.ExecutionModel.Server.RunQuery(QueryRunner runner)
    
    C:\temp>echo %errorlevel%
    0
    
    C:\temp>lprun6 -lang=p ret1.linq
    
    C:\temp>echo %errorlevel%
    0
    
    C:\temp>
    

    As a sanity check, I ran it with linqpad5 again and it seemed to do the right thing.

    C:\temp>lprun|findstr Version
    Version=5.40.00(AnyCPU)
    
    C:\temp>lprun -lang=p throw.linq
    Exception: foo
       at UserQuery.Main() in C:\temp\throw.linq:line 3
       at LINQPad.ExecutionModel.ClrQueryRunner.Run()
       at LINQPad.ExecutionModel.Server.RunQuery(QueryRunner runner)
    
    C:\temp>echo %errorlevel%
    1
    
    C:\temp>lprun -lang=p ret1.linq
    
    C:\temp>echo %errorlevel%
    1
    
  • Looks like the fix didn't make that beta. There will be another release very soon.

Sign In or Register to comment.