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=-1.0 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE,UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 31130 invoked from network); 20 Aug 2020 11:28:38 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 20 Aug 2020 11:28:38 -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:Content-Transfer-Encoding: Content-Type:MIME-Version:Message-ID:Subject:To:From:Date:Reply-To:Cc: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References; bh=11oYHXn4d05bXIGJJeBViEC3LcDPX4Rf2xpHXJKXyck=; b=Z0ONzvaSrXl9dYPiG5CD0zWuTP VFFJMV9VAjMzD1Dp1mPM6KK3fq3MVdBiBcVGYyWatxRxg1gc3UfdGeDOxF8j8gJ249faKKCwsH5i+ qIHFjAFReavLbd+VVqa5g1iXyymE6l+4XyykQTAsUaknx8gt/uLlVu2qEVWxINgsDCp0UDFxEnMJp 7e2sjMEysCyXxV/tW0KweyUexVFeQnUnh+foKw+KEvy4eMZfkqf0pHJq6y8LNBwm1RKMAQKGte5+q 9AOi4An5htbjJ13atumuVQcLpXZXSpfclxAwklavvdgZJOxreqp+hPzqRD1OdsXHKJ2vB7f8GJ6az Hjb0CMog==; Received: from authenticated user by zero.zsh.org with local id 1k8ikH-00081C-6z; Thu, 20 Aug 2020 11:28:37 +0000 Authentication-Results: zsh.org; iprev=pass (joooj.vinc17.net) smtp.remote-ip=155.133.131.76; dmarc=skipped; arc=none Received: from joooj.vinc17.net ([155.133.131.76]:41840) by zero.zsh.org with esmtps (TLS1.3:TLS_AES_256_GCM_SHA384:256) id 1k8ijx-0007sI-4p; Thu, 20 Aug 2020 11:28:18 +0000 Received: from smtp-zira.vinc17.net (128.119.75.86.rev.sfr.net [86.75.119.128]) by joooj.vinc17.net (Postfix) with ESMTPSA id E40033D1; Thu, 20 Aug 2020 13:28:15 +0200 (CEST) Received: by zira.vinc17.org (Postfix, from userid 1000) id 8EE91C223F6; Thu, 20 Aug 2020 13:28:15 +0200 (CEST) Date: Thu, 20 Aug 2020 13:28:15 +0200 From: Vincent Lefevre To: zsh-workers@zsh.org Subject: command -p should enable builtins not in path Message-ID: <20200820112815.GA216072@zira.vinc17.org> Mail-Followup-To: zsh-workers@zsh.org MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit X-Mailer-Info: https://www.vinc17.net/mutt/ User-Agent: Mutt/1.14.5+76 (bb407ec3) vl-127292 (2020-06-24) X-Zsh-Org-Should-ARC-Sign: true X-Seq: 47330 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: Though zsh isn't meant to conform to POSIX, it should follow its requirements when they make sense. https://pubs.opengroup.org/onlinepubs/9699919799/utilities/command.html says: The following options shall be supported: -p Perform the command search using a default value for PATH that is guaranteed to find all of the standard utilities. ^^^ So, in particular, the standard utility "cd" must be found. Note that the above sentence does not mean that the utility must be somewhere in $PATH, just that the used PATH value allows the shell to find the utility; in case of a builtin utility (like "cd"), this will just run the utility without needing PATH. This works with all usual shells, except zsh: zira% sh -c "command -p cd /tmp; pwd" /tmp zira% bash -c "command -p cd /tmp; pwd" /tmp zira% ksh -c "command -p cd /tmp; pwd" /tmp zira% zsh -c "command -p cd /tmp; pwd" zsh:1: command not found: cd /home/vinc17 zira% echo $ZSH_VERSION 5.8 Setting the POSIX_BUILTINS option allows "cd" to be found, but with the drawback that it will not disable builtins that are in $PATH. So this option is a bad solution when using "zmodload zsh/files" without -F, for instance. Note: "command -p cd ..." is used by Intel's script to set up environment variables for its compiler. -- Vincent Lefèvre - Web: 100% accessible validated (X)HTML - Blog: Work: CR INRIA - computer arithmetic / AriC project (LIP, ENS-Lyon)