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

Re: Subshells and parameters



On May 17,  4:24pm, Vincent Lefevre wrote:
} Subject: Re: Subshells and parameters
}
} On 2006-05-12 22:05:23 -0400, Lloyd Zusman wrote:
} > I'm wondering if there's a solution that doesn't require a separate
} > executable.
} 
} You need a module, but this isn't implemented yet.

As someone pointed out earlier, you can fork a new copy of zsh to find
this information; to split hairs, that's a separate process, but not a
separate executable.

Example:

    getpid() { typeset -g PID=$(exec $ZSH_NAME -fc 'print $PPID') }

The exec is important, otherwise you spawn two processes and get the
PID of the intermediate descendant.

Compare:

    getpid; print $$ $PID
    ( getpid; print $$ $PID )



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