From owner-freebsd-questions@freebsd.org Fri Oct 28 02:21:28 2016 Return-Path: Delivered-To: freebsd-questions@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 36A24C23D1F for ; Fri, 28 Oct 2016 02:21:28 +0000 (UTC) (envelope-from jd1008@gmail.com) Received: from mail-oi0-x22f.google.com (mail-oi0-x22f.google.com [IPv6:2607:f8b0:4003:c06::22f]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id ED1146CE for ; Fri, 28 Oct 2016 02:21:27 +0000 (UTC) (envelope-from jd1008@gmail.com) Received: by mail-oi0-x22f.google.com with SMTP id y2so92595860oie.0 for ; Thu, 27 Oct 2016 19:21:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=subject:to:references:from:message-id:date:user-agent:mime-version :in-reply-to:content-transfer-encoding; bh=rpiVen/7TiA0T+/JQgiIV8fwRUQXqC/sUXKJJxMP+54=; b=boCpHClSZuujYl+j0Ie3MtJRbKUyqK14MMbt/V/W6WjfKRRhsEZ6lbnXsQ7ptH5ovH uaK7NG6pPhO0oRUoQOLDpCpVA4xx1PwgptDqlP4mL3wdmSNJuibTTZ57ZfCJsDUkUPyP rYjbXz/WStGikaO0cNl3cNeiFQPyQgdkWshXcJgp1CBRmqu7Wx+fK9H47dfljHY2tKYK k+nRJF/NbW5TTAPbG3jNaeAnapeNuqus6mN0XA8oyNjSOc4bYK7AQ91dF93yuTFwzrMH 8KA/TKC0s7KqbV4dfaNKT+lRVmiGLEd7TiwNbspn5RPDJ7CklGUnt9KTq/sLRl99NneB 8+Wg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding; bh=rpiVen/7TiA0T+/JQgiIV8fwRUQXqC/sUXKJJxMP+54=; b=NTfJlx1SkxdP6VvIww2I1eKk/R5eMU818LyLmmDb0tR43KLSDhpyJ8yW4+/G/5y8yM XXHPVGgFYN3zCGe605xy3G6ZsHzbT/vZmd7+6Pee88SdUiNyvJVmfHkw0+bdePQO9I0r q9VOBCKDCooMoM+rjnAqwMjX19UNSJL6DtklLqEc/3ho9zAuq/tNdclV7+js9iX5my4N bkpVCeiU5dhazymsDPTh7Vex/ryD1F0KY104sfe+nkrFaHXfMJGGuSgiNHwSEBUpuk9G N6sJ5bXEUkRPjhK22dX8o0OSZVRx2PWNcQyvOLkX69xV6/HmwClp9K5Q5Act/iDfnbhC Dq0w== X-Gm-Message-State: ABUngveVbw/FpO0FH1w10XqApNhjdwMZOMo++YSbdXFYx6jYaN04vslBm+NBc9X1vVR6/Q== X-Received: by 10.107.136.65 with SMTP id k62mr8797998iod.99.1477621286930; Thu, 27 Oct 2016 19:21:26 -0700 (PDT) Received: from localhost.localdomain (50-243-4-3-static.hfc.comcastbusiness.net. [50.243.4.3]) by smtp.googlemail.com with ESMTPSA id r66sm4098467iod.24.2016.10.27.19.21.25 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 27 Oct 2016 19:21:26 -0700 (PDT) Subject: Re: Interesting $0 Problem To: freebsd-questions@freebsd.org References: <20161028014923.GA11638@fedora24> From: jd1008 Message-ID: <5812B617.5070701@gmail.com> Date: Thu, 27 Oct 2016 20:21:11 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.0.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 28 Oct 2016 02:21:28 -0000 That's because your PATH variable first searched /usr/local/bin so that is the name of the shell that is running. For example, from the command line: $ echo $0 -ksh and my PATH variable looks like this: $ echo $PATH /sbin:/usr/sbin:/bin:/usr/bin:/usr/libexec:/usr/local/bin:/opt/bin:/opt/schily/bin/: So, my entry in the password file says my shell is /bin/ksh $ grep jd /etc/passwd jd:x:108o:1080:jd:/home/jd:/bin/ksh HTH. On 10/27/2016 07:53 PM, Tim Daneliuk wrote: > On 10/27/2016 08:49 PM, Dutch Ingraham wrote: >> On Thu, Oct 27, 2016 at 08:30:40PM -0500, Tim Daneliuk wrote: >>> I was fidding with some shell code today and discovered it was breaking >>> because $0 was returning "-/usr/local/bin/bash". Why is there a leading >>> dash here? I've not seen that before. >> How are you invoking the expansion, i.e., from a file or the >> command-line? Is this a login shell? >> >> What do you get from the command-line with ? >> _______________________________________________ >> freebsd-questions@freebsd.org mailing list >> https://lists.freebsd.org/mailman/listinfo/freebsd-questions >> To unsubscribe, send any mail to "freebsd-questions-unsubscribe@freebsd.org" >> > > My .bashrc source as standard startup profile: > > . mystartup > > Inside mystartup the folloing statement exists: > > source foo.sh > > $0 as reported in foo.sh is coming back with "-/usr/local/bin/bash"... >