Start an interactive shell in an ephemeral directory.
Invoke shstash
with no arguments to start a new interactive shell.
% shstash % pwd /private/var/tmp/shstash-015562507
Arguments to shstash
are passed through to the shell.
The ephemeral directory is automatically removed after the shell terminates.
% echo $SHLVL 1 % shstash -c 'echo $SHLVL && pwd' 2 /private/var/tmp/shstash-613225361 % stat /private/var/tmp/shstash-613225361 stat: /private/var/tmp/shstash-613225361: stat: No such file or directory
Ephemeral directories are created beneath /var/tmp
by default. On many Unix-like operating systems, the entries beneath this directory are not automatically removed with the passage of time, which can be a useful property when conducting long-running experiments on scratch data. An alternative root directory, which must already exist, may be specified with SHSTASH_ROOT
.
% SHSTASH_ROOT=~/stash shstash -c pwd /Users/saj/stash/shstash-023063755
Shell exit status is propagated.
% shstash -c 'exit 123' % echo $? 123
Shell selection is influenced by the values of the SHSTASH_SHELL
and SHELL
environment variables. SHSTASH_SHELL
need not be a true shell. The value of the PATH
environment variable is used to resolve non-absolute paths.
% SHSTASH_SHELL=pwd shstash /private/var/tmp/shstash-102865235
% SHSTASH_SHELL=python shstash -c 'import os; print(os.getcwd())' /private/var/tmp/shstash-038481734
The shell is terminated, and the ephemeral directory is removed, upon receipt of SIGINT
, SIGTERM
, or SIGQUIT
.
% shstash -c 'pwd && mkfifo foo && cat foo' & ; pid=$! ; sleep 3 ; kill $pid [1] 98738 /private/var/tmp/shstash-676656683 % [1] + exit 143 shstash -c 'pwd && mkfifo foo && cat foo' % stat /private/var/tmp/shstash-676656683 stat: /private/var/tmp/shstash-676656683: stat: No such file or directory
shstash
signals its child with SIGTERM
upon receipt of SIGINT
or SIGTERM
. shstash
signals its child with SIGKILL
upon receipt of SIGQUIT
.