From owner-freebsd-questions@freebsd.org Fri Oct 28 02:30:41 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 DD753C240B0 for ; Fri, 28 Oct 2016 02:30:41 +0000 (UTC) (envelope-from galtsev@kicp.uchicago.edu) Received: from cosmo.uchicago.edu (cosmo.uchicago.edu [128.135.70.90]) by mx1.freebsd.org (Postfix) with ESMTP id BE021CC7 for ; Fri, 28 Oct 2016 02:30:41 +0000 (UTC) (envelope-from galtsev@kicp.uchicago.edu) Received: by cosmo.uchicago.edu (Postfix, from userid 48) id 4E2B8CB8CA1; Thu, 27 Oct 2016 21:30:35 -0500 (CDT) Received: from 128.135.52.6 (SquirrelMail authenticated user valeri) by cosmo.uchicago.edu with HTTP; Thu, 27 Oct 2016 21:30:35 -0500 (CDT) Message-ID: <27078.128.135.52.6.1477621835.squirrel@cosmo.uchicago.edu> In-Reply-To: <5812B617.5070701@gmail.com> References: <20161028014923.GA11638@fedora24> <5812B617.5070701@gmail.com> Date: Thu, 27 Oct 2016 21:30:35 -0500 (CDT) Subject: Re: Interesting $0 Problem From: "Valeri Galtsev" To: "jd1008" Cc: freebsd-questions@freebsd.org Reply-To: galtsev@kicp.uchicago.edu User-Agent: SquirrelMail/1.4.8-5.el5.centos.7 MIME-Version: 1.0 Content-Type: text/plain;charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-Priority: 3 (Normal) Importance: Normal 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:30:42 -0000 On Thu, October 27, 2016 9:21 pm, jd1008 wrote: > 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 He refers to the leading hyphen, which, BTW, you have too. I for one do not see leading hyphen: [valeri@point ~]$ echo $0 bash [valeri@point ~]$ zsh point% echo $0 zsh point% /usr/local/bin/bash [valeri@point ~]$ echo $0 /usr/local/bin/bash You see, in neither of my cases $0 returns hyphen and the command that is being executed, just the command itself. But I don't have answer why you have it different. Valeri > > 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"... >> > > _______________________________________________ > 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" > ++++++++++++++++++++++++++++++++++++++++ Valeri Galtsev Sr System Administrator Department of Astronomy and Astrophysics Kavli Institute for Cosmological Physics University of Chicago Phone: 773-702-4247 ++++++++++++++++++++++++++++++++++++++++