我在我的树莓派上使用 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
怎么会发生这种事呢?
答案1
正在运行的可执行文件将知道完整的调用命令行,并且可以根据调用它的名称修改其行为。对于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
标志,并根据标志是否已设置而表现不同。