help-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Help-bash] run at global level form a function?


From: Dan Douglas
Subject: Re: [Help-bash] run at global level form a function?
Date: Tue, 24 Feb 2015 17:25:33 -0600

On Tue, Feb 24, 2015 at 4:37 PM, Patrick Schleizer <address@hidden> wrote:
> Hi,
>
> let's say one is within a bash function.
>
> Is it possible to do stuff within a bash function as if it was executed
> outside a function?
>
> Let's see if such a feature exists. If not, I'll describe what I really
> want to do a bit better.
>
> Cheers,
> Patrick
>

You can assign (write only) to the global scope of the current
subshell using `declare -g'. It sounds like you want something more
than that. Bash doesn't provide a longjmp-like construct and it's not
possible to run code from another context without returning.

You can walk the stack in ksh93 with the debug trap, but setting
.sh.level then modifying state is extremely fragile. I'm sure it would
be the same deal in bash, though it has no equivalent feature yet.

-- 
Dan Douglas



reply via email to

[Prev in Thread] Current Thread [Next in Thread]