From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 8879 invoked by alias); 29 Aug 2017 02:28:19 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: X-Seq: 41621 Received: (qmail 18130 invoked by uid 1010); 29 Aug 2017 02:28:19 -0000 X-Qmail-Scanner-Diagnostics: from out2-smtp.messagingengine.com by f.primenet.com.au (envelope-from , uid 7791) with qmail-scanner-2.11 (clamdscan: 0.99.2/21882. spamassassin: 3.4.1. Clear:RC:0(66.111.4.26):SA:0(-2.6/5.0):. Processed in 0.88055 secs); 29 Aug 2017 02:28:19 -0000 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,T_DKIM_INVALID autolearn=ham autolearn_force=no version=3.4.1 X-Envelope-From: d.s@daniel.shahaf.name X-Qmail-Scanner-Mime-Attachments: | X-Qmail-Scanner-Zip-Files: | DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= daniel.shahaf.name; h=date:from:in-reply-to:message-id :references:subject:to:x-me-sender:x-me-sender:x-sasl-enc :x-sasl-enc; s=fm1; bh=qtt5L7Sel4AseJCRpQ5YXesuwdqZLMAkD7ihRwIU2 rg=; b=ln1/X9tv1rJurlB5MiNrmgDWyejmgHAc4NM5UYyxV64CwIQ82Q6aUc8uj 9sh2nUgc1zHonAl2QaKEhC8q5Oqg0ktqxdYQjuGqDFD0d/aZj4e5SZ2yM+kYDzdV 54HV2FJ4rKFIne2DXsSLEPb4RYvD4axby+gXFWXimNPviPveYIcadKGeA32rL2xV SmRQ7AsGhX8ruiI22gGHiubyaBes0NjUyLzzXih691VkUdtAzg4QkROvtJYkOwfn L3bK9qcvU572/MMSv7EBVwn0+cbJ9xhzW1Kr5aUgFCAcBphx8gHBiVRE91xUV9Y/ j1ytDZe9dvPxqUNpmGupozl9Gpfaw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=date:from:in-reply-to:message-id :references:subject:to:x-me-sender:x-me-sender:x-sasl-enc :x-sasl-enc; s=fm1; bh=qtt5L7Sel4AseJCRpQ5YXesuwdqZLMAkD7ihRwIU2 rg=; b=J/0UOQIMegM8ZxU+nQ095LlnhR9w9O+TIIPWEzTnmhYUqq5k4IFqTuyJF Rk8jjy2SWFEppEao2guQI9ErgF66O4PH9btnfnFSYKC1U8jhwpHFbtCkUa3paHiz BU8tx81V364gfgh2fHDNlHmEyyM2ehSNf00GlWgM9qSqlylR7w+aWT/K7jBlt2l2 JYnPn5Cp9OzFGEBrQyMeKCEqsNvFzAO6fB/9wrhyGid0E59dRPzvNIK8osDEUapo L6bh1I7aEyyWxbqyj6Q8/ho5vVTWFssERkJc6iLBMuYTJULh4kz1OkvY6pKAdObZ v6SB7C1cVirKpoO4S1Q7wg8M2P9fg== X-ME-Sender: X-Sasl-enc: cEXg8mWYaTRDV7GVX+cUy5OiC1NmrpCBB+Mg6RjOGTe7 1503973695 From: Daniel Shahaf To: zsh-workers@zsh.org Subject: [PATCH 2/2] _mkdir: Honour the 'command' and 'builtin' precommand modifiers. Date: Tue, 29 Aug 2017 02:28:10 +0000 Message-Id: <20170829022810.485-2-danielsh@tarpaulin.shahaf.local2> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170829022810.485-1-danielsh@tarpaulin.shahaf.local2> References: <20170829022810.485-1-danielsh@tarpaulin.shahaf.local2> --- Hi, This patch implements the "once a way is found out" comment that it removes. It works correctly on linux: % mkdir DEBUG: variant=gnu % zmodload zsh/files % mkdir DEBUG: variant=zsh ... but it would be good if someone could confirm that it still works on $OSTYPE == (freebsd|dragonfly)* as well: the code special-cases those $OSTYPE's. Thanks, Daniel Completion/Unix/Command/_mkdir | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/Completion/Unix/Command/_mkdir b/Completion/Unix/Command/_mkdir index b104d3d60..7e8ff121a 100644 --- a/Completion/Unix/Command/_mkdir +++ b/Completion/Unix/Command/_mkdir @@ -9,22 +9,21 @@ args=( '(-)*: :->directories' ) -_pick_variant -r variant gnu=gnu zsh='\(eval\)' $OSTYPE --help # It can still happen that there is a precommand command or builtin in the line. # In such cases, the variant has to be modified suitably, after further checking # the variant of the _command_ mkdir. - -# I currently don't know of any way to find out what precommands are present on -# the line. The variant should be modified like this once a way is found out: - -# if [[ $variant == zsh ]]; then -# if [[ $precommand = *command* ]]; then -# _mkdir_command () { command mkdir "$@" } -# _pick_variant -c _mkdir_command -r variant gnu=gnu unix --help -# fi -# elif [[ $precommand = *builtin* ]]; then -# variant=zsh -# fi +# +# $precommands is defined in _main_complete +if (( ${+precommands[(r)command]} )); then + _mkdir_command () { command mkdir "$@" } + _pick_variant -c _mkdir_command -r variant gnu=gnu unix --help + unfunction _mkdir_command +elif (( ${+precommands[(r)builtin]} )) || (( ${+builtins[mkdir]} )) || [[ "$(type -w mkdir)" == "*: builtin" ]]; then + variant=zsh +else + _pick_variant -r variant gnu=gnu zsh='\(eval\)' $OSTYPE --help +fi +# Now $variant is set. case $variant in gnu|freebsd*|dragonfly*)