繁体   English   中英

在终端脚本和shell脚本中运行命令有什么区别?

[英]What is the difference of running commands in terminal and shell script?

在终端中运行命令时,我想检查tmux别名是否存在:

$ type -t tmux

结果是

$ alias

但是,当我将“ type -t tmux”放入外壳脚本并运行时,结果是

$ ./test.sh
$ file

为什么结果不同?

我的test.sh是:

#!/usr/bin/env bash
set -e

type -t tmux

tmux应该读取并尊重.bash_profile定义的任何别名,但.bashrc中不读取任何别名。

调用test.sh是一个子过程,除非您从source test.sh环境,否则不会使用当前过程中的环境,但这也允许该脚本修改当前环境。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM