linux系统中whereis的用法详解

萧红SEO SEO爱好者,分享SEO经验~

linux/Unix可以使用 whereis 这个命令来查找某个特定的程序和命令的二进制文件()、源代码和man手册的位置,貌似现在还能看到软件的配置文件的位置(路径).

命令作用:

查找二进制文件位置,查找软件的配置文件的位置,查找源代码文件位置,查看man手册位置.

语法,基本语法如下:

  1. whereiscommand
  2. OR
  3. whereisprogram
  4. OR
  5. whereis[options]program
  6. OR
  7. whereis-BMSdirectory-fcommand

whereis 使用举例:

查找 date 命令的 可执行文件、源代码和man手册的位置,输入:

$ whereis date

如何只搜索二进制文件的位置?

使用 -b 参数:$ whereis -b date

如何只搜索man手册的位置?

使用 -m 参数:$ whereis -m date

如何只搜索源代码文件的位置?

使用 -s 参数:$ whereis -s date

问题:whereis -u参数是有问题的,按照man whereis 的说明,-u的就是搜索那些没有二进制文件或者源代码文件或者man手册的文件的,但是实际测试发现,和这毛关系都没有啊.

man手册上的一个例子:

A file is said to be unusual if it does not have one entry of each requested type. Thus the following example, asks for those files in the current directory which have no documentation(意思是搜索当前目录下,没有man文档的文件):

$ whereis -m -u *

我们先cd /bin,然后执行上面的命令,会发现 whereis -m -u * 和 where -m * 结果是一模一样的,-u的功能完全没体现出来,而且与man文档描述的完全不符,因为/bin目录下的文件都是有man文档的,按man文档的意思,结果应该是空的,但是结果却不是空的.

如何限制搜索的路径?

使用下面的参数限制对应的搜索路径:

-B /path/to/dir:限制在指定的目录搜索二进制文件.

-M /path/to/dir:限制在指定的目录搜索man手册文件.

-S /path/to/dir:限制在指定的目录搜索二进制文件.

在使用了-B , -M , -S 任意一个参数时,必须加上 -f 参数,然后指定要搜索的文件名.

实例如下:只在 /bin 目录下搜索 ls 和gcc的:$ whereis -B /bin -f ls gcc

结果如下:

  1. ls:/bin/ls/usr/share/man/man1/ls.1.gz
  2. gcc:

可以看到,gcc在/bin目录下搜索二进制文件是没有结果的,说明gcc的二进制文件不在 /bin目录下.

问题:但是,我发现,虽然/bin目录下没有gcc二进制文件,但是使用上面的命令照样有输出,而不是像我翻译的这篇文章那样.

实例2:这也是man手册上的例子,经测试,这里 -u参数还是和man手册上描述的不符合,查找所有/usr/bin目录下的,其man文档不在 /usr/man/man1/,且其源代码文件不在/usr/src/ 的 文件,输入:

  1. #cd/usr/bin
  2. #whereis-u-ms-M/usr/man/man1-S/usr/src-f*
  3. //测试:
  4. #cd/bin
  5. #whereis-u-m-M/root-f*

按man手册的意思,这行命令的功能是:查找 所有/bin下,其man文档不在/root的文件,所以应该是有结果输出的,因为/root目录下根本没有任何文件的man手册,可以,惊奇的发现,结果居然是空的.

  1. whereiscommandoptions
  2. Fromthewhereis(1)commandmanpage:
  3. OptionMeaning
  4. -fDefinesearchscope.
  5. -bSearchonlybinaries.
  6. -BDefinebinarieslookuppath.
  7. -mSearchonlymanualpaths.
  8. -MDefinemanlookuppath.
  9. -sSearchonlysourcespath.
  10. -SDefinesourceslookuppath.
  11. -uSearchfromunusualenties.
  12. -VOutputversioninformationandexit.无效的,man文档无此参数
  13. -hDisplaythishelpandexit.无效的,man文档无此参数
  14. SEEALSO
  15. whereis(1)Linux/Unixcommandmanpage
  16. CategoryListofUnixandLinuxcommands
  17. FileManagementcat
  18. NetworkUtilitiesdig•host•ip
  19. ProcessesManagementbg•chroot•disown•fg•jobs•kill•killall•pwdx•time•pidof•pstree
  20. Searchingwhereis•which
  21. UserInformationgroups•id•last•lastcomm•logname•users•w•who•whoami•lid•members

关于whereis 的 -u参数的功能,因为不知道whereis的版本,不好查找对应版本的whereis的源代码,我从网上找了个新版本的whereis的c源代码,明显的发现,whereis使用hard-coded paths.

whereis在git上的代码地址:https://github.com/karelzak/util-linux/blob/master/misc-utils/whereis.c#L96

代码如下:

  1. /*-
  2. *Copyright(c)1980TheRegentsoftheUniversityofCalifornia.
  3. *Allrightsreserved.
  4. *
  5. *Redistributionanduseinsourceandbinaryforms,withorwithout
  6. *modification,arepermittedprovidedthatthefollowingconditions
  7. *aremet:
  8. *1.Redistributionsofsourcecodemustretaintheabovecopyright
  9. *notice,thislistofconditionsandthefollowingdisclaimer.
  10. *2.Redistributionsinbinaryformmustreproducetheabovecopyright
  11. *notice,thislistofconditionsandthefollowingdisclaimerinthe
  12. *documentationand/orothermaterialsprovidedwiththedistribution.
  13. *3.Alladvertisingmaterialsmentioningfeaturesoruseofthissoftware
  14. *mustdisplaythefollowingacknowledgement:
  15. *ThisproductincludessoftwaredevelopedbytheUniversityof
  16. *California,Berkeleyanditscontributors.
  17. *4.NeitherthenameoftheUniversitynorthenamesofitscontributors
  18. *maybeusedtoendorseorpromoteproductsderivedfromthissoftware
  19. *withoutspecificpriorwrittenpermission.
  20. *
  21. *THISSOFTWAREISPROVIDEDBYTHEREGENTSANDCONTRIBUTORS``ASIS''AND
  22. *ANYEXPRESSORIMPLIEDWARRANTIES,INCLUDING,BUTNOTLIMITEDTO,THE
  23. *IMPLIEDWARRANTIESOFMERCHANTABILITYANDFITNESSFORAPARTICULARPURPOSE
  24. *AREDISCLAIMED.INNOEVENTSHALLTHEREGENTSORCONTRIBUTORSBELIABLE
  25. *FORANYDIRECT,INDIRECT,INCIDENTAL,SPECIAL,EXEMPLARY,ORCONSEQUENTIAL
  26. *DAMAGES(INCLUDING,BUTNOTLIMITEDTO,PROCUREMENTOFSUBSTITUTEGOODS
  27. *ORSERVICES;LOSSOFUSE,DATA,ORPROFITS;ORBUSINESSINTERRUPTION)
  28. *HOWEVERCAUSEDANDONANYTHEORYOFLIABILITY,WHETHERINCONTRACT,STRICT
  29. *LIABILITY,ORTORT(INCLUDINGNEGLIGENCEOROTHERWISE)ARISINGINANYWAY
  30. *OUTOFTHEUSEOFTHISSOFTWARE,EVENIFADVISEDOFTHEPOSSIBILITYOF
  31. *SUCHDAMAGE.
  32. *
  33. *1999-02-22ArkadiuszMi?kiewicz<misiek@pld.ORG.PL>
  34. *-addedNativeLanguageSupport
  35. *2011-08-12DavidlohrBueso<dave@gnu.org>
  36. *-added$PATHlookup
  37. *
  38. *Copyright(C)2013KarelZak<kzak@redhat.com>
  39. *2013SamiKerola<kerolasa@iki.fi>
  40. */
  41. #include<sys/param.h>
  42. #include<sys/types.h>
  43. #include<sys/stat.h>
  44. #include<dirent.h>
  45. #include<stdio.h>
  46. #include<stdlib.h>
  47. #include<string.h>
  48. #include<ctype.h>
  49. #include<assert.h>
  50. #include"xalloc.h"
  51. #include"nls.h"
  52. #include"c.h"
  53. #include"closestream.h"
  54. #include"canonicalize.h"
  55. #include"debug.h"
  56. UL_DEBUG_DEFINE_MASK(whereis);
  57. UL_DEBUG_DEFINE_MASKNAMES(whereis)=UL_DEBUG_EMPTY_MASKNAMES;
  58. #defineWHEREIS_DEBUG_INIT(1<<1)
  59. #defineWHEREIS_DEBUG_PATH(1<<2)
  60. #defineWHEREIS_DEBUG_ENV(1<<3)
  61. #defineWHEREIS_DEBUG_ARGV(1<<4)
  62. #defineWHEREIS_DEBUG_SEARCH(1<<5)
  63. #defineWHEREIS_DEBUG_STATIC(1<<6)
  64. #defineWHEREIS_DEBUG_LIST(1<<7)
  65. #defineWHEREIS_DEBUG_ALL0xFFFF
  66. #defineDBG(m,x)__UL_DBG(whereis,WHEREIS_DEBUG_,m,x)
  67. #defineON_DBG(m,x)__UL_DBG_CALL(whereis,WHEREIS_DEBUG_,m,x)
  68. staticcharuflag=0;
  69. /*supportedtypes*/
  70. enum{
  71. BIN_DIR=(1<<1),
  72. MAN_DIR=(1<<2),
  73. SRC_DIR=(1<<3),
  74. ALL_DIRS=BIN_DIR|MAN_DIR|SRC_DIR
  75. };
  76. /*directories*/
  77. structwh_dirlist{
  78. inttype;
  79. dev_tst_dev;
  80. ino_tst_ino;
  81. char*path;
  82. structwh_dirlist*next;
  83. };
  84. staticconstchar*bindirs[]={
  85. "/usr/bin",
  86. "/usr/sbin",
  87. "/usr/lib",
  88. "/usr/lib64",
  89. "/bin",
  90. "/sbin",
  91. "/etc",
  92. "/usr/etc",
  93. "/lib",
  94. "/lib64",
  95. "/usr/games",
  96. "/usr/games/bin",
  97. "/usr/games/lib",
  98. "/usr/emacs/etc",
  99. "/usr/lib/emacs/*/etc",
  100. "/usr/TeX/bin",
  101. "/usr/tex/bin",
  102. "/usr/interviews/bin/LINUX",
  103. "/usr/X11R6/bin",
  104. "/usr/X386/bin",
  105. "/usr/bin/X11",
  106. "/usr/X11/bin",
  107. "/usr/X11R5/bin",
  108. "/usr/local/bin",
  109. "/usr/local/sbin",
  110. "/usr/local/etc",
  111. "/usr/local/lib",
  112. "/usr/local/games",
  113. "/usr/local/games/bin",
  114. "/usr/local/emacs/etc",
  115. "/usr/local/TeX/bin",
  116. "/usr/local/tex/bin",
  117. "/usr/local/bin/X11",
  118. "/usr/contrib",
  119. "/usr/hosts",
  120. "/usr/include",
  121. "/usr/g++-include",
  122. "/usr/ucb",
  123. "/usr/old",
  124. "/usr/new",
  125. "/usr/local",
  126. "/usr/libexec",
  127. "/usr/share",
  128. "/opt/*/bin",
  129. NULL
  130. };
  131. staticconstchar*mandirs[]={
  132. "/usr/man/*",
  133. "/usr/share/man/*",
  134. "/usr/X386/man/*",
  135. "/usr/X11/man/*",
  136. "/usr/TeX/man/*",
  137. "/usr/interviews/man/mann",
  138. "/usr/share/info",
  139. NULL
  140. };
  141. staticconstchar*srcdirs[]={
  142. "/usr/src/*",
  143. "/usr/src/lib/libc/*",
  144. "/usr/src/lib/libc/net/*",
  145. "/usr/src/ucb/pascal",
  146. "/usr/src/ucb/pascal/utilities",
  147. "/usr/src/undoc",
  148. NULL
  149. };
  150. staticvoidwhereis_init_debug(void)
  151. {
  152. __UL_INIT_DEBUG(whereis,WHEREIS_DEBUG_,0,WHEREIS_DEBUG);
  153. }
  154. staticconstchar*whereis_type_to_name(inttype)
  155. {
  156. switch(type){
  157. caseBIN_DIR:return"bin";
  158. caseMAN_DIR:return"man";
  159. caseSRC_DIR:return"src";
  160. default:return"???";
  161. }
  162. }
  163. staticvoid__attribute__((__noreturn__))usage(FILE*out)
  164. {
  165. fputs(USAGE_HEADER,out);
  166. fprintf(out,_("%s[options]<file>\n"),program_invocation_short_name);
  167. fputs(USAGE_SEPARATOR,out);
  168. fputs(_("Locatethebinary,source,andmanual-pagefilesforacommand.\n"),out);
  169. fputs(USAGE_OPTIONS,out);
  170. fputs(_("-bsearchonlyforbinaries\n"),out);
  171. fputs(_("-B<dirs>definebinarieslookuppath\n"),out);
  172. fputs(_("-msearchonlyformanualsandinfos\n"),out);
  173. fputs(_("-M<dirs>definemanandinfolookuppath\n"),out);
  174. fputs(_("-ssearchonlyforsources\n"),out);
  175. fputs(_("-S<dirs>definesourceslookuppath\n"),out);
  176. fputs(_("-fterminate<dirs>argumentlist\n"),out);
  177. fputs(_("-usearchforunusualentries\n"),out);
  178. fputs(_("-loutputeffectivelookuppaths\n"),out);
  179. fprintf(out,USAGE_MAN_TAIL("whereis(1)"));
  180. exit(out==stderr?EXIT_FAILURE:EXIT_SUCCESS);
  181. }
  182. staticvoiddirlist_add_dir(structwh_dirlist**ls0,inttype,constchar*dir)
  183. {
  184. structstatst;
  185. structwh_dirlist*prev=NULL,*ls=*ls0;
  186. if(access(dir,R_OK)!=0)
  187. return;
  188. if(stat(dir,&st)!=0||!S_ISDIR(st.st_mode))
  189. return;
  190. while(ls){
  191. if(ls->st_ino==st.st_ino&&
  192. ls->st_dev==st.st_dev&&
  193. ls->type==type){
  194. DBG(LIST,ul_debugobj(*ls0,"ignore(alreadyinlist):%s",dir));
  195. return;
  196. }
  197. prev=ls;
  198. ls=ls->next;
  199. }
  200. ls=xcalloc(1,sizeof(*ls));
  201. ls->st_ino=st.st_ino;
  202. ls->st_dev=st.st_dev;
  203. ls->type=type;
  204. ls->path=canonicalize_path(dir);
  205. if(!*ls0)
  206. *ls0=ls;/*firstinthelist*/
  207. else{
  208. assert(prev);
  209. prev->next=ls;/*addtotheendofthelist*/
  210. }
  211. DBG(LIST,ul_debugobj(*ls0,"adddir:%s",ls->path));
  212. return;
  213. }
  214. /*specialcasefor'*'inthepaths*/
  215. staticvoiddirlist_add_subdir(structwh_dirlist**ls,inttype,constchar*dir)
  216. {
  217. charbuf[PATH_MAX],*d;
  218. DIR*dirp;
  219. structdirent*dp;
  220. strncpy(buf,dir,PATH_MAX);
  221. buf[PATH_MAX-1]='\0';
  222. d=strchr(buf,'*');
  223. if(!d)
  224. return;
  225. *d=0;
  226. dirp=opendir(buf);
  227. if(!dirp)
  228. return;
  229. DBG(LIST,ul_debugobj(*ls,"scanningsubdir:%s",dir));
  230. while((dp=readdir(dirp))!=NULL){
  231. if(!strcmp(dp->d_name,".")||!strcmp(dp->d_name,".."))
  232. continue;
  233. snprintf(d,PATH_MAX-(d-buf),"%s",dp->d_name);
  234. /*adirdefinitioncanhaveastarinmiddleofpath*/
  235. strcat(buf,strchr(dir,'*')+1);
  236. dirlist_add_dir(ls,type,buf);
  237. }
  238. closedir(dirp);
  239. return;
  240. }
  241. staticvoidconstruct_dirlist_from_env(constchar*env,
  242. structwh_dirlist**ls,
  243. inttype)
  244. {
  245. char*key=NULL,*tok=NULL,*pathcp,*path=getenv(env);
  246. if(!path)
  247. return;
  248. pathcp=xstrdup(path);
  249. DBG(ENV,ul_debugobj(*ls,"construct%sdirlistfrom:%s",
  250. whereis_type_to_name(type),path));
  251. for(tok=strtok_r(pathcp,":",&key);tok;
  252. tok=strtok_r(NULL,":",&key))
  253. dirlist_add_dir(ls,type,tok);
  254. free(pathcp);
  255. return;
  256. }
  257. staticvoidconstruct_dirlist_from_argv(structwh_dirlist**ls,
  258. int*idx,
  259. intargc,
  260. char*argv[],
  261. inttype)
  262. {
  263. inti;
  264. DBG(ARGV,ul_debugobj(*ls,"construct%sdirlistfromargv[%d..]",
  265. whereis_type_to_name(type),*idx));
  266. for(i=*idx;i<argc;i++){
  267. if(*argv[i]=='-')/*endofthelist*/
  268. break;
  269. DBG(ARGV,ul_debugobj(*ls,"usingargv[%d]:%s",*idx,argv[*idx]));
  270. dirlist_add_dir(ls,type,argv[i]);
  271. *idx=i;
  272. }
  273. return;
  274. }
  275. staticvoidconstruct_dirlist(structwh_dirlist**ls,
  276. inttype,
  277. constchar**paths)
  278. {
  279. size_ti;
  280. DBG(STATIC,ul_debugobj(*ls,"construct%sdirlistfromstaticarray",
  281. whereis_type_to_name(type)));
  282. for(i=0;paths[i];i++){
  283. if(!strchr(paths[i],'*'))
  284. dirlist_add_dir(ls,type,paths[i]);
  285. else
  286. dirlist_add_subdir(ls,type,paths[i]);
  287. }
  288. return;
  289. }
  290. staticvoidfree_dirlist(structwh_dirlist**ls0,inttype)
  291. {
  292. structwh_dirlist*prev=NULL,*next,*ls=*ls0;
  293. *ls0=NULL;
  294. DBG(LIST,ul_debugobj(*ls0,"freedirlist"));
  295. while(ls){
  296. if(ls->type&type){
  297. next=ls->next;
  298. DBG(LIST,ul_debugobj(*ls0,"free:%s",ls->path));
  299. free(ls->path);
  300. free(ls);
  301. ls=next;
  302. if(prev)
  303. prev->next=ls;
  304. }else{
  305. if(!prev)
  306. *ls0=ls;/*firstunremoved*/
  307. prev=ls;
  308. ls=ls->next;
  309. }
  310. }
  311. return;
  312. }
  313. staticintfilename_equal(constchar*cp,constchar*dp)
  314. {
  315. inti=strlen(dp);
  316. DBG(SEARCH,ul_debug("compare'%s'and'%s'",cp,dp));
  317. if(dp[0]=='s'&&dp[1]=='.'&&filename_equal(cp,dp+2))
  318. return1;
  319. if(!strcmp(dp+i-2,".Z"))
  320. i-=2;
  321. elseif(!strcmp(dp+i-3,".gz"))
  322. i-=3;
  323. elseif(!strcmp(dp+i-3,".xz"))
  324. i-=3;
  325. elseif(!strcmp(dp+i-4,".bz2"))
  326. i-=4;
  327. while(*cp&&*dp&&*cp==*dp)
  328. cp++,dp++,i--;
  329. if(*cp==0&&*dp==0)
  330. return1;
  331. while(isdigit(*dp))
  332. dp++;
  333. if(*cp==0&&*dp++=='.'){
  334. --i;
  335. while(i>0&&*dp)
  336. if(--i,*dp++=='.')
  337. return(*dp++=='C'&&*dp++==0);
  338. return1;
  339. }
  340. return0;
  341. }
  342. staticvoidfindin(constchar*dir,constchar*pattern,int*count,char**wait)
  343. {
  344. DIR*dirp;
  345. structdirent*dp;
  346. dirp=opendir(dir);
  347. if(dirp==NULL)
  348. return;
  349. DBG(SEARCH,ul_debug("find'%s'in'%s'",pattern,dir));
  350. while((dp=readdir(dirp))!=NULL){
  351. if(!filename_equal(pattern,dp->d_name))
  352. continue;
  353. if(uflag&&*count==0)
  354. xasprintf(wait,"%s/%s",dir,dp->d_name);
  355. elseif(uflag&&*count==1&&*wait){
  356. printf("%s:%s%s/%s",pattern,*wait,dir,dp->d_name);
  357. free(*wait);
  358. *wait=NULL;
  359. }else
  360. printf("%s/%s",dir,dp->d_name);
  361. ++(*count);
  362. }
  363. closedir(dirp);
  364. return;
  365. }
  366. staticvoidlookup(constchar*pattern,structwh_dirlist*ls,intwant)
  367. {
  368. charpatbuf[PATH_MAX];
  369. intcount=0;
  370. char*wait=NULL,*p;
  371. /*canonicalizepattern--removepathsuffixetc.*/
  372. p=strrchr(pattern,'/');
  373. p=p?p+1:(char*)pattern;
  374. strncpy(patbuf,p,PATH_MAX);
  375. patbuf[PATH_MAX-1]='\0';
  376. DBG(SEARCH,ul_debug("lookupdirsfor'%s'(%s),want:%s%s%s",
  377. patbuf,pattern,
  378. want&BIN_DIR?"bin":"",
  379. want&MAN_DIR?"min":"",
  380. want&SRC_DIR?"src":""));
  381. p=strrchr(patbuf,'.');
  382. if(p)
  383. *p='\0';
  384. if(!uflag)
  385. /*if-unotspecifiedthenwealwaysprintthepattern*/
  386. printf("%s:",patbuf);
  387. for(;ls;ls=ls->next){
  388. if((ls->type&want)&&ls->path)
  389. findin(ls->path,patbuf,&count,&wait);
  390. }
  391. free(wait);
  392. if(!uflag||(uflag&&count>1))
  393. putchar('\n');
  394. return;
  395. }
  396. staticvoidlist_dirlist(structwh_dirlist*ls)
  397. {
  398. while(ls){
  399. if(ls->path){
  400. switch(ls->type){
  401. caseBIN_DIR:
  402. printf("bin:");
  403. break;
  404. caseMAN_DIR:
  405. printf("man:");
  406. break;
  407. caseSRC_DIR:
  408. printf("src:");
  409. break;
  410. default:
  411. abort();
  412. }
  413. printf("%s\n",ls->path);
  414. }
  415. ls=ls->next;
  416. }
  417. }
  418. intmain(intargc,char**argv)
  419. {
  420. structwh_dirlist*ls=NULL;
  421. intwant=ALL_DIRS;
  422. inti,want_resetable=0;
  423. setlocale(LC_ALL,"");
  424. bindtextdomain(PACKAGE,LOCALEDIR);
  425. textdomain(PACKAGE);
  426. atexit(close_stdout);
  427. if(argc==1)
  428. usage(stderr);
  429. whereis_init_debug();
  430. construct_dirlist(&ls,BIN_DIR,bindirs);
  431. construct_dirlist_from_env("PATH",&ls,BIN_DIR);
  432. construct_dirlist(&ls,MAN_DIR,mandirs);
  433. construct_dirlist_from_env("MANPATH",&ls,MAN_DIR);
  434. construct_dirlist(&ls,SRC_DIR,srcdirs);
  435. for(i=1;i<argc;i++){
  436. constchar*arg=argv[i];
  437. intarg_i=i;
  438. DBG(ARGV,ul_debug("argv[%d]:%s",i,arg));
  439. if(*arg!='-'){
  440. lookup(arg,ls,want);
  441. /*
  442. *Thelookupmask("want")iscumulativeandit's
  443. *resetableonlywhenithasbeenalreadyused.
  444. *
  445. *whereis-b-mfoo:'foo'mask=BIN|MAN
  446. *whereis-bfoobar:'foo'and'bar'mask=BIN|MAN
  447. *whereis-bfoo-mbar:'foo'mask=BIN;'bar'mask=MAN
  448. */
  449. want_resetable=1;
  450. continue;
  451. }
  452. for(++arg;arg&&*arg;arg++){
  453. DBG(ARGV,ul_debug("arg:%s",arg));
  454. switch(*arg){
  455. case'f':
  456. break;
  457. case'u':
  458. uflag=1;
  459. break;
  460. case'B':
  461. if(*(arg+1))
  462. usage(stderr);
  463. i++;
  464. free_dirlist(&ls,BIN_DIR);
  465. construct_dirlist_from_argv(
  466. &ls,&i,argc,argv,BIN_DIR);
  467. break;
  468. case'M':
  469. if(*(arg+1))
  470. usage(stderr);
  471. i++;
  472. free_dirlist(&ls,MAN_DIR);
  473. construct_dirlist_from_argv(
  474. &ls,&i,argc,argv,MAN_DIR);
  475. break;
  476. case'S':
  477. if(*(arg+1))
  478. usage(stderr);
  479. i++;
  480. free_dirlist(&ls,SRC_DIR);
  481. construct_dirlist_from_argv(
  482. &ls,&i,argc,argv,SRC_DIR);
  483. break;
  484. case'b':
  485. if(want_resetable){
  486. want=ALL_DIRS;
  487. want_resetable=0;
  488. }
  489. want=want==ALL_DIRS?BIN_DIR:want|BIN_DIR;
  490. break;
  491. case'm':
  492. if(want_resetable){
  493. want=ALL_DIRS;
  494. want_resetable=0;
  495. }
  496. want=want==ALL_DIRS?MAN_DIR:want|MAN_DIR;
  497. break;
  498. case's':
  499. if(want_resetable){
  500. want=ALL_DIRS;
  501. want_resetable=0;
  502. }
  503. want=want==ALL_DIRS?SRC_DIR:want|SRC_DIR;
  504. break;
  505. case'l':
  506. list_dirlist(ls);
  507. break;
  508. case'V':
  509. printf(UTIL_LINUX_VERSION);
  510. returnEXIT_SUCCESS;
  511. case'h':
  512. usage(stdout);
  513. default:
  514. usage(stderr);
  515. }
  516. if(arg_i<i)/*movedtothenextargv[]item*/
  517. break;//phpfensi.com
  518. }
  519. }
  520. free_dirlist(&ls,ALL_DIRS);
  521. returnEXIT_SUCCESS;
  522. }

靠,就连代码注释都有错误,懒得折腾了,哥还有事要做,反正 -u 参数实际很少使用的,有兴趣的可以看下这代码.

相关广告
  • linux系统中whereis的用法详解 linux系统中whereis的用法详解 linux系统中whereis的用法详解
相关阅读

linux系统中whereis的用法详解

2019/10/10 17:46:21 | 谷歌SEO算法 | Dropbox