zsh-workers
 help / Atom feed
* How to restore $? AND $_ ?
@ 2019-07-24  6:20 Sebastian Gniazdowski
  2019-07-24  6:29 ` Sebastian Gniazdowski
  0 siblings, 1 reply; 2+ messages in thread
From: Sebastian Gniazdowski @ 2019-07-24  6:20 UTC (permalink / raw)
  To: Zsh hackers list

Hello,
consider the following:

sched-fun() {
    # UND=$_
    local ret=$?

    sched +1 "sched-fun \$_"

    # : $UND
    return $ret
}

The point is that the 2 commented lines must be run in the same place
as the next lines after them in order to work. No way out of this
problem? It is about not disrupting user session with background
tasks, I think that this is in general important.
-- 
Sebastian Gniazdowski
News: https://twitter.com/ZdharmaI
IRC: https://kiwiirc.com/client/chat.freenode.net:+6697/#zplugin
Blog: http://zdharma.org

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: How to restore $? AND $_ ?
  2019-07-24  6:20 How to restore $? AND $_ ? Sebastian Gniazdowski
@ 2019-07-24  6:29 ` Sebastian Gniazdowski
  0 siblings, 0 replies; 2+ messages in thread
From: Sebastian Gniazdowski @ 2019-07-24  6:29 UTC (permalink / raw)
  To: Zsh hackers list

False alarm – Zsh pushes the $_ values onto some kind of stack:

() { : test2 } test1; echo $_
test1

so appending $_ to the sched's argument is sufficient.

On Wed, 24 Jul 2019 at 08:20, Sebastian Gniazdowski
<sgniazdowski@gmail.com> wrote:
>
> Hello,
> consider the following:
>
> sched-fun() {
>     # UND=$_
>     local ret=$?
>
>     sched +1 "sched-fun \$_"
>
>     # : $UND
>     return $ret
> }
>
> The point is that the 2 commented lines must be run in the same place
> as the next lines after them in order to work. No way out of this
> problem? It is about not disrupting user session with background
> tasks, I think that this is in general important.
> --
> Sebastian Gniazdowski
> News: https://twitter.com/ZdharmaI
> IRC: https://kiwiirc.com/client/chat.freenode.net:+6697/#zplugin
> Blog: http://zdharma.org



-- 
Sebastian Gniazdowski
News: https://twitter.com/ZdharmaI
IRC: https://kiwiirc.com/client/chat.freenode.net:+6697/#zplugin
Blog: http://zdharma.org

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, back to index

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-07-24  6:20 How to restore $? AND $_ ? Sebastian Gniazdowski
2019-07-24  6:29 ` Sebastian Gniazdowski

zsh-workers

Archives are clonable: git clone --mirror http://inbox.vuxu.org/zsh-workers

Newsgroup available over NNTP:
	nntp://inbox.vuxu.org/vuxu.archive.zsh.workers


AGPL code for this site: git clone https://public-inbox.org/ public-inbox