sta*_*tti 4 unix linux bash shell
我想做点什么:
do lots of stuff to prepare a good environement
become_interactive
#wait for Ctrl-D
automatically clean up
Run Code Online (Sandbox Code Playgroud)
bash有可能吗?如果没有,你看到另一种做同样事情的方法吗?
结构如下:
test.sh
#!/bin/sh
exec bash --rcfile environ.sh
Run Code Online (Sandbox Code Playgroud)
environ.sh
cleanup() {
echo "Cleaning up"
}
trap cleanup EXIT
echo "Initializing"
PS1='>> '
Run Code Online (Sandbox Code Playgroud)
在行动:
~$ ./test.sh
Initializing
>> exit
Cleaning up
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
245 次 |
最近记录: |