Path: csiph.com!goblin3!goblin1!goblin.stu.neva.ru!usenet.stanford.edu!not-for-mail From: Martijn Dekker Newsgroups: gnu.bash.bug Subject: Re: Should [[ -v 1 ]] be supported? Date: Thu, 27 Dec 2018 22:11:44 +0100 Lines: 20 Approved: bug-bash@gnu.org Message-ID: References: <5dac2cf2-2fac-0fd1-058f-6a84a3271738@case.edu> NNTP-Posting-Host: lists.gnu.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-Trace: usenet.stanford.edu 1545945541 4408 208.118.235.17 (27 Dec 2018 21:19:01 GMT) X-Complaints-To: action@cs.stanford.edu To: bug-bash@gnu.org Envelope-to: bug-bash@gnu.org User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.11; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 In-Reply-To: <5dac2cf2-2fac-0fd1-058f-6a84a3271738@case.edu> Content-Language: en-GB X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy] X-Received-From: 37.59.109.123 X-BeenThere: bug-bash@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Bug reports for the GNU Bourne Again SHell List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Xref: csiph.com gnu.bash.bug:14972 Op 27-12-18 om 19:22 schreef Chet Ramey: > On 12/26/18 10:49 PM, Peng Yu wrote: > >> Although [[ -z ${1+s} ]] and (($#)) works for testing if $1 is set, >> neither of them are uniformly better performance wise. In this case, >> should [[ -v 1 ]] be supported? > > So you're saying that neither of the existing options performs better > than the other, though they both perform well, so we should add some > new capability just because? That's a particularly poor argument. Consistency might be a better argument. If [[ -v foo ]] is equivalent to [[ -n ${foo+s} ]] for variables (with the advantage that you don't need 'eval' to handle arbitrary values of 'foo'), then perhaps it's not unreasonable to expect [[ -v 1 ]] to be equivalent to [[ -n ${1+s} ]]. FWIW, zsh and mksh do support this; ksh93 doesn't. - M.