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

Re: logout from interactive subshell



"Com MN PG P E B Consultant 3"
<mn-pg-p-e-b-consultant-3.com@xxxxxxxxxxx> writes:

>> How about
>> function rlogin() {command rlogin "$@"; exit}
>> ?
>
> Hmmmm.... I don't see how this could help me. Actually, your
> solution would EXIT the shell I came from, after the login
> has finished!! So I not only have to type all the "exit"s on
> the remote host, I would even loose my current shell on the
> local host.
>
> Maybe to repeat what I would like to do:
>
> A typical application would go like this:
>
>    rlogin foobar
>    DO SOME STUFF
>    cleartool setview myview # this creates a subshell
>    DO MORE STUFF
>    cleartool setview yourview # now I'm two subshells deep
>    DO STILL MORE STUFF
>    # Now I want to exit
>    exit
>    exit
>    logout
>
> I would like to have a (interactive) command which does the final two
> exits plus
> a logout for me.
>
> BTW, I could imagine a solution using 'expect', which does the login,
> then hands
> over the control to the user, and finally if the user is done, performs
> the
> exit and logout.

With clearcase in the picture, this becomes complicated, due to the fact
that cleartool automatically puts you into a subshell whether you like
it or not.  That's one of several reasons for why I don't like
clearcase.

But given that you're probably stuck having to use it, you might try
something like this (assuming that you're using zsh):

Put this into your ~/.zlogin:

  [[ ${SHLVL:-0} == 1 ]] && {
    export LOGINPID=$$
  }

Then, after your "# Now I want to exit" comment (above), do this:

  kill -9 $LOGINPID

You can make this into an alias, if you wish.

It's an ugly hack, but it may be the only thing that you can do, given
that you're using clearcase.

I think it will work, but I can't test it, because clearcase isn't
installed on any of my machines.

Good luck!


-- 
 Lloyd Zusman
 ljz@xxxxxxxxxx
 God bless you.



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