From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-3.4 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED,UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 13374 invoked from network); 21 Jan 2021 21:48:07 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 21 Jan 2021 21:48:07 -0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=zsh.org; s=rsa-20200801; h=List-Archive:List-Owner:List-Post:List-Unsubscribe: List-Subscribe:List-Help:List-Id:Sender:Message-ID:Date: Content-Transfer-Encoding:Content-ID:Content-Type:MIME-Version:Subject:To: References:From:In-reply-to:cc:Reply-To:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID; bh=bBI1qIuqUiSzNat2sHBntEzq/oslCJf1O8Jdd3fNUds=; b=Mh+Oq23URMIQpYBtXJZ3LvWd0F 5QO7ic5p5X7869Tiqr5EWwXjnxf/9Ra03sNgKV7LbeJzspOKIDTNUNAlS0lcUzmo98ulSzwdk7++7 iEsUSUocuSJVfvpYll5VzTfGKCBiXFsfsMdBlJWazOBraiGxoxCnMLdG2hLVPbZ7NghS1J3PrOT5C lMe80xVzzJ4tSXlaw1asC2cRdWVTDTfJL8fTj23MxG4JiKQd9Mnhn7Ye7Vw4NEdZoRJqQI4F8gkoU FTjAXWZQOuUTtWWcFQ2ZbVEfraVG8lhZCD3fsmDjyFDW5xKlZWHZ4gdt3THgSRqBHySuMxiKtHBUf Ae5Zgs9w==; Received: from authenticated user by zero.zsh.org with local id 1l2hoE-000BiN-HL; Thu, 21 Jan 2021 21:48:06 +0000 Received: from authenticated user by zero.zsh.org with esmtpsa (TLS1.3:TLS_AES_256_GCM_SHA384:256) id 1l2hnw-000BZ8-Vz; Thu, 21 Jan 2021 21:47:49 +0000 Received: from [192.168.178.21] (helo=hydra) by mail.kiddle.eu with esmtp(Exim 4.93.0.4) (envelope-from ) id 1l2hnu-000NuR-He; Thu, 21 Jan 2021 22:47:47 +0100 cc: Zsh hackers list In-reply-to: From: Oliver Kiddle References: To: Bart Schaefer Subject: Re: compinit in emulation MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-ID: <91909.1611265666.1@hydra> Content-Transfer-Encoding: 8bit Date: Thu, 21 Jan 2021 22:47:46 +0100 Message-ID: <91910-1611265666.544073@yljT.3NHd.u6Oz> X-Seq: 47859 Archived-At: X-Loop: zsh-workers@zsh.org Errors-To: zsh-workers-owner@zsh.org Precedence: list Precedence: bulk Sender: zsh-workers-request@zsh.org X-no-archive: yes List-Id: List-Help: List-Subscribe: List-Unsubscribe: List-Post: List-Owner: List-Archive: Archived-At: Bart Schaefer wrote: > The documentation says: > If the parameter _compdir is set, compinit uses it as a directory where > completion functions can be found; this is only necessary if they are > not already in the function search path. I'm not entirely clear what that feature is trying to achieve. So you can wipe out $fpath but set _compdir to the location of the completon functions and compinit will kindly fill out $fpath with all the completion directories again. Assuming zsh can still find compinit in $fpath in order to run it that is. This may relate to compaudit and compinstall so Peter may have more idea. > However, this depends on the fpath/FPATH tied variable linkage, which > is disabled when not in native zsh mode. I wrongly expected 'emulate > -R zsh' to fix this, and spent quite a while down a rabbit hole trying > to figure out what was wrong. I get "compinit:141: parse error: condition expected: $1" when trying to use the feature from sh emulation - is that what you're referring to? When cutting it down to the absolute minimum, I can reproduce that odd error by creating a file that contains just: [[ $1 = (*) ]] Then (assuming it is named compinit): zsh -f fpath=( $PWD ) autoload -UTz compinit compinit compinit:1: parse error: condition expected: $1 That line won't parse in other shells. The lexer gives different results – compare with and without sh emulation: print -lr -- "${(z):-[[ \$1 = (#b)(*)=(*) ]]}" So despite the use of emulate -L zsh in top of a function, emulate sh causes sh lexer rules to be applied to the autoloaded function. Perhaps the -z option to autoload could be overloaded and made to correct for that. The original lines in compinit are as follows. There may be ways such as wrapping in eval or emulate or rearranging to workaround the real problem. (Assuming your issue wasn't something else entirely) 391 pattern) 392 if [[ $1 = (#b)(*)=(*) ]]; then 393 _patcomps[$match[1]]="=$match[2]=$func" Oliver