命令的输出与其符号链接的输出不匹配

0 symlink command apropos

我在我的树莓派上使用 RASPBIAN。我发现命令“apropos”是命令“wahtis”的符号链接。但是,当使用相同的参数时,这些命令的输出不匹配:

$ whatis delete
delete: nothing appropriate.
Run Code Online (Sandbox Code Playgroud)

$ 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....***
Run Code Online (Sandbox Code Playgroud)

很明显,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
Run Code Online (Sandbox Code Playgroud)

怎么会这样?

use*_*274 5

正在运行的可执行文件将知道完整的调用命令行,并且可以根据调用它的名称修改其行为。对于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 {
Run Code Online (Sandbox Code Playgroud)

在处理过程中还有十几个地方会检查am_apropos标志,并根据是否已设置而表现不同。