Symlink
命令的輸出與其符號連結的輸出不匹配
我在我的樹莓派上使用 RASPBIAN。我發現命令“apropos”是命令“wahtis”的符號連結。但是,當使用相同的參數時,這些命令的輸出不匹配:
$ whatis delete delete: nothing appropriate.
但
$ apropos delete argz_delete (3) - functions to handle an argz list delete_module (2) - unload a kernel module dphys-swapfile (8) - set up, mount/unmount, and delete an swap file git-branch (1) - List, create, or delete branches git-replace (1) - Create, list, delete refs to replace objects git-symbolic-ref (1) - Read, modify and delete symbolic refs git-tag (1) - Create, list, delete or verify a tag object signed ***output is truncated to save space....***
很明顯,apropos 是 whatis 的符號連結。
pi@raspberry:~ $ which apropos /usr/bin/apropos pi@raspberry:~ $ ls -l /usr/bin/apropos lrwxrwxrwx 1 root root 6 Aug 24 2017 /usr/bin/apropos -> whatis
怎麼會這樣?
正在執行的執行檔將知道完整的呼叫命令行,並且可以根據呼叫它的名稱修改其行為。對於
apropos
/的具體實例whatis
,您可以在原始碼(連結的最新版本的第 895 行附近)中看到,首先要做的是確定命令是否被名稱呼叫apropos
:int main (int argc, char *argv[]) { #ifdef HAVE_ICONV char *locale_charset; #endif int status = OK; program_name = base_name (argv[0]); if (STREQ (program_name, APROPOS_NAME)) { am_apropos = 1; argp_program_version = "apropos " PACKAGE_VERSION; } else {
在處理過程中還有大約十幾個地方檢查
am_apropos
標誌,並且根據它是否已設置而表現不同。