Correct, I use this frequently to drop out of subshells and functions.

Recent example (after rewriting my UWIN /etc/profile, to better
understand what's happening there):

function append_path {
        nameref path=${1:?} || return
        shift
        typeset dir
        for dir; do
                [[ -d ${dir:?} ]] 2>& - || continue
                path="${path:+$path:}$dir"
        done
}
 ...
append_path PATH $(unixpath ${NTRESKIT:+"$NTRESKIT"} 2>& -)
append_path PATH /usr/X11/bin && export DISPLAY=localhost:0
append_path PATH /sys /win
 ...

The nameref and its argument have to succeed, so I let ${1:?} do the
work of complaining.
The || return will return the original value of $? to the caller.

Notes on this code sample:
1) I'm conveniently leaving out the reg search for the w2k reskit and
the msdev stuff here.

2) For interactive use, I've been using functions like 'use <arg>'  and
'forget <arg>' that will
prepend or remove the first matching .../<arg>/bin to/from PATH for
common values of '...' (/usr, /opt).
I might post some of that on github.

Cheers,
Henk



On Mon, Apr 23, 2012, at 09:47 AM, Chet Ramey wrote:
> On 4/23/12 9:11 AM, ольга крыжановская wrote:
> > Clark, you must use exit $? and not exit without arguments.
> 
> Why?  The shell has never required that, and Posix makes it explicit.
> 
> -- 
> ``The lyf so short, the craft so long to lerne.'' - Chaucer
>                ``Ars longa, vita brevis'' - Hippocrates
> Chet Ramey, ITS, CWRU    [email protected]   
> http://cnswww.cns.cwru.edu/~chet/
> _______________________________________________
> ast-users mailing list
> [email protected]
> https://mailman.research.att.com/mailman/listinfo/ast-users

_______________________________________________
ast-users mailing list
[email protected]
https://mailman.research.att.com/mailman/listinfo/ast-users

Reply via email to