论点我去寻找类似的东西,可能就是找不到它,所以我做了以下两个脚本。首先,说shellstate
,然后可能至少set -i
和set -o emacs
这reset_shellstate
不会为你做。我不知道一种方法来问问bash它认为哪些变量是特殊的。
~/bin/reset_shellstate
:
#!/bin/bash
__="$PWD/shellstate_${1#_}"
trap '
declare -p >"'"$__"'"
trap >>"'"$__"'"
echo cd \""$PWD"\" >>"'"$__"'" # setting PWD did this already, but...
echo set +abefhikmnptuvxBCEHPT >>"'"$__"'"
echo set -$- >>"'"$__"'" # must be last before sed, see $s/s//2 below
sed -ri '\''
$s/s//2
s,^trap --,trap,
/^declare -[^ ]*r/d
/^declare -[^ ]* [A-Za-z0-9_]*[^A-Za-z0-9_=]/d
/^declare -[^ ]* [^= ]*_SESSION_/d
/^declare -[^ ]* BASH[=_]/d
/^declare -[^ ]* (DISPLAY|GROUPS|SHLVL|XAUTHORITY)=/d
/^declare -[^ ]* WINDOW(ID|PATH)=/d
'\'' "'"$__"'"
shopt -op >>"'"$__"'"
shopt -p >>"'"$__"'"
declare -f >>"'"$__"'"
echo "Shell state saved in '"$__"'"
' 0
unset __
~/bin/shellstate
:
#!/bin/bash
shellstate=shellstate_${1#_}
test -s $shellstate || reset_shellstate $1
shift
bash --noprofile --init-file shellstate_${1#_} -is "[email protected]"
exit $?
我需要做一些工作用C a.sh和b.sh的执行之间,所以这是不可能的,以B键。请注意,我对shell变量感兴趣,而不是环境变量。 – danvk 2010-07-11 17:38:03
啊,对不起! – eruciform 2010-07-11 18:41:36