diff options
| author | tv <tv@iiso> | 2011-09-20 15:09:19 +0200 |
|---|---|---|
| committer | tv <tv@iiso> | 2011-09-20 15:09:19 +0200 |
| commit | b3a318886407c98b3e91df9173c2d9c2cf195de3 (patch) | |
| tree | 5fc1dffda896b1a06a15981bc5c977adc41f8e5d /hyper | |
| parent | 08a6dc70d957912c864516ad705c7c724f363b73 (diff) | |
//hyper spawn: use well known //proc dir
this commit also spawns the command in the current $PWD so
spawn ls & co. are viable commands.
this commit also sets up a trap for TERM, so dash behaves nicely, again.
also we now've got more documentation and debug output [if called with
sh -x].
Diffstat (limited to 'hyper')
| -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