簡體   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