From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 22835 invoked by alias); 10 Sep 2017 18:57:35 -0000 Mailing-List: contact zsh-users-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Users List List-Post: List-Help: X-Seq: 22887 Received: (qmail 23627 invoked by uid 1010); 10 Sep 2017 18:57:35 -0000 X-Qmail-Scanner-Diagnostics: from mpv3-2015.cwru.edu 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(129.22.103.194):SA:0(-1.9/5.0):. Processed in 3.559493 secs); 10 Sep 2017 18:57:35 -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.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.1 X-Envelope-From: chet.ramey@case.edu X-Qmail-Scanner-Mime-Attachments: | X-Qmail-Scanner-Zip-Files: | Reply-To: chet.ramey@case.edu Cc: chet.ramey@case.edu Subject: Re: Running "unset path" breaks PATH despite emulation being enabled To: Bart Schaefer , zsh-users@zsh.org References: <20170908082917.v5j4vczoq75vs5lk@sinister.lan.codevat.com> <20170909213806.52qezvyk766loeg3@sinister.lan.codevat.com> <170909152512.ZM9176@torch.brasslantern.com> From: Chet Ramey Organization: ITS, Case Western Reserve University Message-ID: <2ca0606c-3c56-8275-e9b2-a8159d018b80@case.edu> Date: Sun, 10 Sep 2017 14:51:15 -0400 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.12; rv:52.0) Gecko/20100101 Thunderbird/52.3.0 MIME-Version: 1.0 In-Reply-To: <170909152512.ZM9176@torch.brasslantern.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-Junkmail-Status: score=7/60, host=mpv3-2015.case.edu X-Junkmail-PrAS-Raw: score=7/60, refid=2.7.2:2017.9.10.174516:17:7.944, ip=, rules=__HAS_REPLYTO, __HAS_CC_HDR, __BOUNCE_CHALLENGE_SUBJ, __BOUNCE_NDR_SUBJ_EXEMPT, __SUBJ_ALPHA_END, __TO_MALFORMED_2, __TO_NAME, __TO_NAME_DIFF_FROM_ACC, __REFERENCES, __HAS_FROM, FROM_EDU_TLD, __HAS_MSGID, __SANE_MSGID, DATE_TZ_NA, __USER_AGENT, __MOZILLA_USER_AGENT, __MIME_VERSION, __IN_REP_TO, __CT, __CT_TEXT_PLAIN, __CTE, __REPLYTO_SAMEAS_FROM_ADDY, __REPLYTO_SAMEAS_FROM_ACC, __FROM_DOMAIN_IN_ANY_CC1, __FROM_DOMAIN_IN_ANY_CC2, __REPLYTO_SAMEAS_FROM_DOMAIN, __ANY_URI, __URI_WITH_PATH, __URI_NO_WWW, __CP_URI_IN_BODY, __FRAUD_MONEY_CURRENCY_DOLLAR, __SUBJ_ALPHA_NEGATE, __URI_IN_BODY, __URI_NOT_IMG, __FORWARDED_MSG, __NO_HTML_TAG_RAW, BODYTEXTP_SIZE_3000_LESS, BODY_SIZE_900_999, __MIME_TEXT_P1, __MIME_TEXT_ONLY, __URI_NS, HTML_00_01, HTML_00_10, __FRAUD_MONEY_CURRENCY, BODY_SIZE_5000_LESS, IN_REP_TO, MSG_THREAD, __FROM_DOMAIN_IN_RCPT, __TO_REAL_NAMES, [TRUNCATED], so=2010-03-03 19:42:08, dmn=2016-08-03-0138 On 9/9/17 6:25 PM, Bart Schaefer wrote: > I just had a look at the Bash sources. Chet will correct me if I'm wrong, > but as far as I can tell if argv[0] is not already at least a partial > path, then $BASH is set by doing a path search for the first matching > executable. Thus $BASH will be "the first one listed in a $PATH folder" > when argv[0] contains no "/" separators, even if the actual executable > came from somewhere else. This is about the best you can do. The only additional thing would be to assume that the executed binary came from the current directory if you can't find it in $PATH, because that's how execve(2) and its siblings work. It's a heuristic based on how the shell is commonly executed, but it can certainly be fooled. -- ``The lyf so short, the craft so long to lerne.'' - Chaucer ``Ars longa, vita brevis'' - Hippocrates Chet Ramey, UTech, CWRU chet@case.edu http://cnswww.cns.cwru.edu/~chet/