Any chance to support finally{}

65 views
Skip to first unread message

Miron

unread,
Mar 3, 2016, 12:46:00 AM3/3/16
to Pash Project
It would be very nice to add support for "finally{}} block.
Not sure I will have time to get over the learning curve to add it myself.
So, thgowing it in for your triage :)

Friedrich von Never

unread,
Mar 3, 2016, 1:08:56 AM3/3/16
to pash-p...@googlegroups.com, Pash Project
Hello. It seems that the finally clause is actually supported by Pash, although its support is far from ideal. I'm trying this example:

Pash> try { 2 + 2 } catch { } finally { 0 }

And it returns me 4 (almost as I would expect, ha-ha). For the record: in PowerShell it returns both 4 and 0 (and I wasn't expecting that honestly).

But we currently doesn't seem to support the finally clause without the catch clause, and that's not right. For example, the following throws an error and kills Pash process (I am not sure it should kill the process at all when failing to parse something btw):

Pash>  try { 2 + 2 } finally { 0 }
System.InvalidOperationException: expected 'finally_clause' to be a 'catch_clauses'

I'll file an issue for that in our bugtracker at https://github.com/Pash-Project/Pash/issues

We're happy to accept any help from you with solving this issue, if you want to fix it.
--
You received this message because you are subscribed to the Google Groups "Pash Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pash-project...@googlegroups.com.
Visit this group at https://groups.google.com/group/pash-project.

Friedrich von Never

unread,
Mar 3, 2016, 1:16:50 AM3/3/16
to pash-p...@googlegroups.com, Pash Project
For your information, I've reported the findings here: https://github.com/Pash-Project/Pash/issues/411

Feel free to comment there.

Miron

unread,
Mar 25, 2016, 2:36:59 PM3/25/16
to Pash Project
Looks like it's checked in. Thank you very - very much. I will test it.
In the meantime question. Is there some way Pash developer community finds the name of the .PS1 script at runtime, while MyInvocation property raises NotImplementedException();

Friedrich von Never

unread,
Mar 26, 2016, 7:34:42 AM3/26/16
to pash-p...@googlegroups.com, Pash Project
First of all, the fix fot finally clauses is still not merged to our main branch, so you'll have to wait for it maybe a couple of days, or just use the branch from https://github.com/Pash-Project/Pash/pull/413 if you really want to.

Thanks for the report about $MyInvocation, I've filed two additional issues based on it:

Unfortunately, it seems that neither $MyInvocation nor $PSScriptRoot are supported currently. Now it has been documented, so we'll hopefully implement these in future.

Thanks for your input, it really helps us to detect features we need to implement.

Jay Bazuzi

unread,
Mar 26, 2016, 12:06:45 PM3/26/16
to pash-p...@googlegroups.com

I have merged that PR.

--
Reply all
Reply to author
Forward
0 new messages