Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: trap signal with functional scope?




On 05.09.2008, at 17:08, Bart Schaefer wrote:

On Sep 5,  2:08pm, Peter Stephenson wrote:
} Subject: Re: trap signal with functional scope?
}
} Sebastian Stark wrote:
} >
} > ssh () {
} >          set_screen_title ${*##-*}
} >          command ssh "$@"
} >          set_screen_title "${HOST/.*}"
} > }
} >
} > Most of the time this just works and is cool. It fails when I send
} > ctrl-c to the ssh process.
}
} Without a suitably recent version of zsh, the answer is probably to
} upgrade.

Isn't this what "setopt localtraps" is for?

   ssh () {
     setopt localtraps
     trap ':' INT
     set_screen_title ${*##-*}
     command ssh "$@"
     set_screen_title "${HOST/.*}"
   }

If your zsh isn't recent enough to have localtraps, see above.

I prefer the {}always{} way, but both proposals helped me learn a lot, thanks.


Sebastian



Messages sorted by: Reverse Date, Date, Thread, Author