From owner-svn-src-head@freebsd.org Thu Sep 24 16:11:53 2020 Return-Path: Delivered-To: svn-src-head@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id C29053FB5F4; Thu, 24 Sep 2020 16:11:53 +0000 (UTC) (envelope-from fernape@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4By0RY4r50z4c7r; Thu, 24 Sep 2020 16:11:53 +0000 (UTC) (envelope-from fernape@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 8A578244CB; Thu, 24 Sep 2020 16:11:53 +0000 (UTC) (envelope-from fernape@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 08OGBrMc024496; Thu, 24 Sep 2020 16:11:53 GMT (envelope-from fernape@FreeBSD.org) Received: (from fernape@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 08OGBrG4024495; Thu, 24 Sep 2020 16:11:53 GMT (envelope-from fernape@FreeBSD.org) Message-Id: <202009241611.08OGBrG4024495@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: fernape set sender to fernape@FreeBSD.org using -f From: =?UTF-8?Q?Fernando_Apestegu=c3=ada?= Date: Thu, 24 Sep 2020 16:11:53 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r366119 - head/usr.bin/which X-SVN-Group: head X-SVN-Commit-Author: fernape X-SVN-Commit-Paths: head/usr.bin/which X-SVN-Commit-Revision: 366119 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.33 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 24 Sep 2020 16:11:53 -0000 Author: fernape (ports committer) Date: Thu Sep 24 16:11:53 2020 New Revision: 366119 URL: https://svnweb.freebsd.org/changeset/base/366119 Log: which(1): Add EXAMPLES section to manpage Add EXAMPLES section showing the use of -a and -s flags and how which(1) treates duplicates. Approved by: manpages (gbe@) Differential Revision: https://reviews.freebsd.org/D26182 Modified: head/usr.bin/which/which.1 Modified: head/usr.bin/which/which.1 ============================================================================== --- head/usr.bin/which/which.1 Thu Sep 24 15:38:01 2020 (r366118) +++ head/usr.bin/which/which.1 Thu Sep 24 16:11:53 2020 (r366119) @@ -29,7 +29,7 @@ .\" .\" $FreeBSD$ .\" -.Dd December 13, 2006 +.Dd September 24, 2020 .Dt WHICH 1 .Os .Sh NAME @@ -62,6 +62,48 @@ command which is similar or identical to this utility. Consult the .Xr builtin 1 manual page. +.Sh EXAMPLES +Locate the +.Xr ls 1 +and +.Xr cp 1 +commands: +.Bd -literal -offset indent +$ /usr/bin/which ls cp +/bin/ls +/bin/cp +.Ed +.Pp +Same as above with a specific +.Va PATH +and showing all occurrences: +.Bd -literal -offset indent +$ PATH=/bin:/rescue /usr/bin/which -a ls cp +/bin/ls +/rescue/ls +/bin/cp +/rescue/cp +.Ed +.Pp +.Nm which +will show duplicates if the same executable is find more than once: +.Bd -literal -offset indent +$ PATH=/bin:/bin /usr/bin/which -a ls +/bin/ls +/bin/ls +.Ed +.Pp +Do not show output. +Just exit with an appropriate return code: +.Bd -literal -offset indent +$ /usr/bin/which -s ls cp +$ echo $? +0 + +$ /usr/bin/which -s fakecommand +$ echo $? +1 +.Ed .Sh SEE ALSO .Xr builtin 1 , .Xr csh 1 ,