Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow try/catch statements to be nested #3

Open
molovo opened this issue Feb 6, 2017 · 1 comment
Open

Allow try/catch statements to be nested #3

molovo opened this issue Feb 6, 2017 · 1 comment
Assignees

Comments

@molovo
Copy link
Owner

molovo commented Feb 6, 2017

This may or may not be possible. The try command needs to launch a subprocess to allow the exception to be caught, which means that modifying the global environment is not possible. To allow statements to be nested we'd need to maintain an 'exception stack' in an array, but cannot do this in its current form due to the use of a subprocess. Thrown exceptions are currently reported back to the global process by echoing the exception and message, so we could maintain the stack outside of the try block, but my first attempt at this didn't work. Something to look into.

@molovo molovo self-assigned this Feb 6, 2017
@daCyberpunk
Copy link

daCyberpunk commented Oct 31, 2020

not really true.
You can use named pipes for it. If I understand your prob right.
This way command is not running in a subprocess.

PIPE=$(mktemp -u)
mkfifo $PIPE
# attach it to file descriptor 3
exec {hlpr}<>$PIPE
# unlink the named pipe
rm $PIPE
command >&$hlpr
echo -ne $'\0' >&$hlpr
read -d$'\0' -u $hlpr output;
# close fd
exec {hlpr}>&-

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants