linux – 有没有办法让shell在脚本中间变得交互?

linux – 有没有办法让shell在脚本中间变得交互?,第1张

概述我想做点什么: do lots of stuff to prepare a good environementbecome_interactive#wait for Ctrl-Dautomatically clean up bash有可能吗?如果没有,你看到另一种做同样事情的方法吗? 结构如下: test.sh #!/bin/shexec bash --rcfile environ.sh 我想做点什么:

do lots of stuff to prepare a good environementbecome_interactive#wait for Ctrl-Dautomatically clean up

bash有可能吗?如果没有,你看到另一种做同样事情的方法吗?

解决方法 结构如下:

test.sh

#!/bin/shexec bash --rcfile environ.sh

environ.sh

cleanup() {    echo "Cleaning up"}trap cleanup EXITecho "Initializing"PS1='>> '

在行动:

~$./test.sh Initializing>> exitCleaning up
总结

以上是内存溢出为你收集整理的linux – 有没有办法让shell在脚本中间变得交互?全部内容,希望文章能够帮你解决linux – 有没有办法让shell在脚本中间变得交互?所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/yw/1027769.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-23
下一篇 2022-05-23

发表评论

登录后才能评论

评论列表(0条)

保存