[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: RFE: make [[ compatible with [ 'Option'?
From: |
Greg Wooledge |
Subject: |
Re: RFE: make [[ compatible with [ 'Option'? |
Date: |
Mon, 28 Mar 2011 14:25:06 -0400 |
User-agent: |
Mutt/1.4.2.3i |
On Mon, Mar 28, 2011 at 10:53:21AM -0700, Linda Walsh wrote:
> if [ ! -e $d/S??sshd ]; then echo "sshd not enabled"; fi
That will fail quite colorfully if the glob matches multiple files.
(Also, "$d" should be quoted.)
On IRC we recommend enabling nullglob, pulling the results of the glob
into an array, and then checking its length.
shopt -s nullglob
files=("$d"/S??sshd)
if (( ${#files[@]} > 0 )); then ...
See also http://mywiki.wooledge.org/BashFAQ/004
In any case, I see no benefit to changing how [[ works. A change would
just cause more confusion.