-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
(筆記)Operating System 裡的 environment variable #128
Comments
什麼是『子程序』呢?就是說,在我目前這個 shell 的情況下,去啟用另一個新的 shell ,新的那個 shell 就是子程序啦!在一般的狀態下,父程序的自訂變數是無法在子程序內使用的。但是透過 export 將變數變成環境變數後,就能夠在子程序底下應用了! |
|
Process Example: process.env.TEST = 1;
console.log(process.env.test);
// => 1 可以在執行時,設定環境變數
|
Heroku dynamic port for your app to bind to.
const PORT = process.env.PORT || 3000;
app.listen(PORT, () => {
console.log(`Our app is running on port ${ PORT }`);
}); |
bash |
命令執行過程:
$PATH 環境變數:
|
|
環境變數例如 PATH、HOME、MAIL、SHELL 等等,都是很重要的
HOME:cd ~ 去到自己的家目錄
SHELL:目前這個環境使用的 SHELL 程式
PATH:執行檔搜尋的路徑~目錄與目錄中間以冒號(:)分隔, 由於檔案的搜尋是依序由 PATH 的變數內的目錄來查詢,所以,目錄的順序也是重要的。
export 指令
如果希望將自訂變數變成環境變數的話,讓該變數內容繼續的在子程序中使用,就執行
如果僅寫 export 而沒有接變數時,此時會把所有的『環境變數』都秀出來
echo 指令
source 指令:讀入環境設定檔的指令
重新讀取修改後的設定檔
設定 EV 範例:Configure the ANDROID_SDK_ROOT environment variable
STEP1
Add the following lines to your $HOME/.bash_profile or $HOME/.bashrc (if you are using zsh then ~/.zprofile or ~/.zshrc) config file:
STEP2
Type source $HOME/.bash_profile for bash or source $HOME/.zprofile to load the config into your current shell.
STEP3
Verify that ANDROID_SDK_ROOT has been set by running echo $ANDROID_SDK_ROOT and the appropriate directories have been added to your path by running echo $PATH.
結論:簡單的整理一下設定環境變數時會用到的 export, source, echo,也引用一句話~在 Linux 的環境下,如果你不懂 bash 是什麼,那麼其他的東西就不用學了
參考文章:
認識與學習BASH
Linux环境变量配置全攻略
The text was updated successfully, but these errors were encountered: