Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm
Precedence: bulk
X-No-Archive: yes
List-Id: Zsh Workers List <zsh-workers.zsh.org>
List-Post: <mailto:zsh-workers@zsh.org>
List-Help: <mailto:zsh-workers-help@zsh.org>
X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on f.primenet.com.au
X-Spam-Level: 
X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,T_DKIM_INVALID
	autolearn=ham autolearn_force=no version=3.4.1
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=brasslantern-com.20150623.gappssmtp.com; s=20150623;
        h=from:message-id:date:in-reply-to:comments:references:to:subject
         :mime-version;
        bh=bBMzpgMV0KepqG+v0tTRJkxs955rT8e4trjIDA5n2hE=;
        b=DHo611qy4aK9ApdS29PAyXHDwi5lGx1V0mYUf2Y/xN30PkEPC54Wb6takadr7ZGgP9
         SreIGWHbg8rJ6z3puFj/gH3qqf/54Aba+rfrdNFRaREoHetv1xwkQJAScltdcjUyD+xP
         LerlsdOPTtFoWf/z++wBeQhBrUONJxXl1mWvBCYnCJNTiPTvuTGeGhlu7aCrsbDempFQ
         bz/sAdfwO2kb28YpnGehiIFyQwbBAjccfCXYGkiX+Ujl0hBDKTs+oTECXwf/c2q3iK0O
         kf44lyvYauO0RDju/IocTJDqppm1QQLtL5PtxVxUcMKVPLJ8JuZFj5TePuaP/xYtDErK
         +aXQ==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20130820;
        h=x-gm-message-state:from:message-id:date:in-reply-to:comments
         :references:to:subject:mime-version;
        bh=bBMzpgMV0KepqG+v0tTRJkxs955rT8e4trjIDA5n2hE=;
        b=D8a3BXEvN8uZi90EZO32Ip8XSTm62/4OhxXCRNUEa35uWjTOJG4Rh3kuDZlxIFJjzo
         ikENESx/3DuYkkga9JtUx33oQm3pUutEAOO49tU8UjGSv4B1wZObhQLKvyebL8S7Kf1Z
         4qmN03N+2MdfsvRCbvZF5iB9BXa99tCfBj3Gd30S7+Qmf8V3iBciDy4EqZqCPqpOR7GK
         NSqwQWM3cwCXBgZFhOQlrVGqoBwg9Tbqj6p/A2qGyvYj5Fs8dUCMDAC/nTAVHTBuKSC5
         HtpNDbbX0fo3FNDWURaIlmj/lCSsGXvfgkuomkfyxAOmxAD3NLMalyLmKszvqz24qWh+
         +DDg==
X-Gm-Message-State: AOPr4FWWev6kOCx8u7ho9Sh+m2uyK/Bg5N/iFGo8BF9RxZWMXOjqa1LtyrB5VsdP8cH4uw==
X-Received: by 10.67.14.7 with SMTP id fc7mr5373558pad.1.1461692160069;
        Tue, 26 Apr 2016 10:36:00 -0700 (PDT)
From: Bart Schaefer <schaefer@brasslantern.com>
Message-Id: <160426103624.ZM11049@torch.brasslantern.com>
Date: Tue, 26 Apr 2016 10:36:24 -0700
In-Reply-To: <CAN3Cs_H0Uz8c7Du53UfvoRcob5zcU8KkNeqHn6vVGaguxNHK9A@mail.gmail.com>
Comments: In reply to Glenn Smith <glennsmith2209@gmail.com>
        "[Patch] No warnings for `rm /*`" (Apr 26, 10:31am)
References: <CAN3Cs_H0Uz8c7Du53UfvoRcob5zcU8KkNeqHn6vVGaguxNHK9A@mail.gmail.com>
X-Mailer: OpenZMail Classic (0.9.2 24April2005)
To: zsh-workers@zsh.org
Subject: Re: [Patch] No warnings for `rm /*`
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
X-Seq: zsh-workers 38350

On Apr 26, 10:31am, Glenn Smith wrote:
} Subject: [Patch] No warnings for `rm /*`
}
} I discovered that zsh warns in every case except `rm /*`.

Thanks.  I think the following simpler patch does the same.

diff --git a/Src/exec.c b/Src/exec.c
index 50eff72..2dcd5bc 100644
--- a/Src/exec.c
+++ b/Src/exec.c
@@ -2902,11 +2902,11 @@ execcmd(Estate state, int input, int output, int how, int last1)
 	    if (s[0] == Star && !s[1]) {
 		if (!checkrmall(pwd))
 		    uremnode(args, node);
-	    } else if (l > 2 && s[l - 2] == '/' && s[l - 1] == Star) {
+	    } else if (l >= 2 && s[l - 2] == '/' && s[l - 1] == Star) {
 		char t = s[l - 2];
 
 		s[l - 2] = 0;
-		if (!checkrmall(s))
+		if (!checkrmall(*s ? s : "/"))
 		    uremnode(args, node);
 		s[l - 2] = t;
 	    }


As an aside:

% rm /nonexistentdir/*
zsh: sure you want to delete all the files in /nonexistentdir [yn]? 

Seems like we could detect when opendir() fails with ENOENT and skip
the prompt, but maybe there are cases of race condition (directory is
created after I type "rm ..." but before /bin/rm is executed?) where
the default answer of "y" would be incorrect.

