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-Qmail-Scanner-Diagnostics: from mail-pa0-f50.google.com by f.primenet.com.au (envelope-from <schaefer@brasslantern.com>, uid 7791) with qmail-scanner-2.11 
 (clamdscan: 0.99.2/21882. spamassassin: 3.4.1.  
 Clear:RC:0(209.85.220.50):SA:0(1.3/5.0):. 
 Processed in 12.295252 secs); 17 Aug 2016 22:36:32 -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=1.3 required=5.0 tests=T_DKIM_INVALID,URI_HEX
	autolearn=no autolearn_force=no version=3.4.1
X-Envelope-From: schaefer@brasslantern.com
X-Qmail-Scanner-Mime-Attachments: |
X-Qmail-Scanner-Zip-Files: |
Received-SPF: none (ns1.primenet.com.au: domain at brasslantern.com does not designate permitted sender hosts)
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=+0Yx8eb61Gt77Vz1ryFaWu/CW12nOXJw7p5i9lQGy0E=;
        b=FSZh7Wk3zmBDSAJlmCHFh5WVuiokRanR/9lX8UPaKODIyCBdrH+6jkk3va6ktnqH0Y
         X+iMhYvWI48ynXBkoqNKESqjeGpiS0Lx7ZCFx6BiyrE4wgXydwjX3f53JIQGRbdsPaW1
         EklLCeiV6m0gUXNMdn+Il+a78kJJN7VHIaXrlxIVA6EROJjF5miLa2UDTWp7WM2YQPfp
         EzIGN6fB518f6P9irEst7AB0LxwWVESSfdIfvH5le/ZG0vXwjHDIJvnURf9DA9xyWk8q
         VVvkZvtwJnYmO31ZJCb6Lrendq/WXrJsHulSIjBwM1Bx+sokPF4zINJRx5YnbyYUqO8s
         CEhA==
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=+0Yx8eb61Gt77Vz1ryFaWu/CW12nOXJw7p5i9lQGy0E=;
        b=ao1JMY/ozui5C9eOjTcGeHBQgc6PH5R40ZVnnYC7+5OfW9rNto/ycart0Mh/yc8DSU
         lhcRbbPBsVCb5OP+LxGuQTCgKIaiaRMzV43x8VzIDnhyQRZyiwKgVf1f9xaXzrrcEQct
         gbZHjbp4kW10uc+5RKJbCtRxl3Kb8Pl+uP0SW9ZyADPnnKzx7+TQO6JH44EQAZL1mls3
         jJY8iHYx0cAjbUtgfBH0r73J8U12pssouBcpwFC/5/Pp6M6Qqlz7AA/UgOIsuTzs7tud
         woZ4s4g2aHh8pF5gRFMrnXMNYtComMtnexKf5fC5BcybycvRdXSSxdbW6CdfwWYI7kbV
         GKUw==
X-Gm-Message-State: AEkoouslf5ybpdd5QOKnbhoeZ8tefTAdx7ZmUUs028icZki98+59OQubi6fWO2DLsA3R/w==
X-Received: by 10.66.132.11 with SMTP id oq11mr12276621pab.4.1471473370773;
        Wed, 17 Aug 2016 15:36:10 -0700 (PDT)
From: Bart Schaefer <schaefer@brasslantern.com>
Message-Id: <160817153618.ZM22548@torch.brasslantern.com>
Date: Wed, 17 Aug 2016 15:36:18 -0700
In-Reply-To: <705fb246-abcf-176b-d4fa-eb0e01cded05@thequod.de>
Comments: In reply to Daniel Hahler <genml+zsh-workers@thequod.de>
        "SSH hostname completion with common suffix and globcomplete inserts characters" (Aug 17,  9:16pm)
References: <705fb246-abcf-176b-d4fa-eb0e01cded05@thequod.de>
X-Mailer: OpenZMail Classic (0.9.2 24April2005)
To: zsh-workers@zsh.org
Subject: Re: SSH hostname completion with common suffix and globcomplete inserts characters
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
X-Seq: zsh-workers 39056

On Aug 17,  9:16pm, Daniel Hahler wrote:
}
} % echo "Host test-05827d88.foo.bar test-6cae9ce0.foo.bar" > ssh_config
} % setopt globcomplete
} % ssh -F ssh_config test-<TAB>
} % ssh -F ssh_config test-|.foo.bar
} % ssh -F ssh_config test-|BR.foo.bar

I compared _complete_debug output for the two cases and there's no
significant difference until the value of compstate[unambiguous] is
displayed near the end, so this looks like an off-by-one error in
the internals.

Cursory examination seems to point to implicit addition/removal of
the "*" pattern at the cursor position when doing globcomplete.  If
instead one explicitly completes

% ssh -F ssh_config test-*<TAB>

then a listing of possible matches appears and the update of the line
is correct.

} The characters being inserted seem to come from the "bar".

I think the characters being inserted are just stack (or heap) garbage;
it may coincidentally be garbage derived from trying a case replacement,
but I don't think that's directly related.

Places to look more closely seem to be computil.c:cfp_opt_pats() and
compcore.c:addmatches(), look for comppatmatch.  For example, most of
cfp_opt_pats() is skipped if the prefix or suffix already contains a
pattern (as in "test-*") but is active if the prefix has no pattern
and comppatmatch is non-empty (as is the case for globcomplete).

