環境變數 PS1 是什麼時候創建的?

環境變數 PS1 是什麼時候創建的?

我一直認為「過去」對 pwd 的提及是非常重要的。如今,我們已經自訂了像 PS1 這樣顯示目前目錄的命令提示符,而 pwd 已經相當過時了。但是 ps1 的想法是什麼時候被引入 *nix 系統的呢?觀看從AT&T的檔案中我可以看出PS1在七十年代絕對不存在。

答案1

該變數是 shell 的一部分,在Bourne shell ( ) 和 中$PS1使用,但在.bashshkshcsh

第一個 UNIX shell 是 Thompson Shell(也稱為sh像後來的 bourne shell,Thompson Shell 通常osh在同時安裝了 Thompson 和 Bourne shell 的系統上呼叫。) Thompson shell 使用該變數$P作為提示符。

然後引入了 Bourne Shell,用於$PS1設定提示符。ksh基於 Bourne Shell,也使用$PS1.使用csh過的。tcshset prompt = <something>

所以我認為第一個使用的 shell$PS1是 Bourne Shell。

湯普森貝殼手冊頁:https://etsh.io/man/osh.1.pdf

Bourne Shell 手冊頁:http://heirloom.sourceforge.net/sh/sh.1.html

相關內容