subshell

    1热度

    1回答

    我有一个调用的bash函数必须在第一次被调用后由EXIT陷阱调用。该函数在陷阱函数退出后立即再次设置陷阱。 echo 0 > .i function launchNextExperiment { (# Run in nested subshell # Implement a mutex lock, not shown j=`cat .i` if [ $j -

    1热度

    6回答

    我想设置一个shell脚本,只有从交互式shell中调用会话才会启动screen会话(或重新加入现有会话)。我所看到的解决方案是检查是否$-包含字母“i”: #!/bin/sh -e echo "Testing interactivity..." echo 'Current value of $- = '"$-" if [ `echo \$- | grep -qs i` ]; then

    1热度

    2回答

    我需要从当前顶级shell运行scriptblocks/scripts,并且我希望它们不改变全局作用域。 到目前为止,我只能够认为以下几种可能: powershell -file <script> powershell -noprofile -command <scriptblock> 的问题是,他们是非常缓慢的。 举例来说,我希望能够做到: mkdir newdir cd newdir