diff options
| -rwxr-xr-x | hyper/process/spawn | 58 |
1 files changed, 45 insertions, 13 deletions
diff --git a/hyper/process/spawn b/hyper/process/spawn index c2b829ca..95854c7d 100755 --- a/hyper/process/spawn +++ b/hyper/process/spawn @@ -1,34 +1,61 @@ #! /bin/sh # -# spawn [command [argument ...]] +# [sh -x] spawn [command [argument ...]] +# +# export id to create&destroy or reuse the working directory //proc/$id/. +# this feature is for debug only and marked as deprecated, so don't rely +# on it too hard. # spawn() { set -euf - # create and change working directory - wd=`mktemp -d` - defer rmdir $wd + # establish working subdirectory in //proc. we're mking only + # transient dirs, i.e. if we mkdir, then we also defer rmdir. + if test -n "${id-}"; then + : "using id=[32;1m$id[m from env" + wd=$pd/$id + if ! test -d $wd; then + : "make transient [32;1m$wd/[m" + mkdir $wd + defer rmdir $wd + elif ! test `ls $wd | wc -l` = 0; then + : "[31;1m$wd/[;31m is not empty