delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2005/03/10/09:26:57

Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com
Date: Thu, 10 Mar 2005 09:22:02 -0500
From: Christopher Faylor <cgf-no-personal-reply-please AT cygwin DOT com>
To: cygwin AT cygwin DOT com
Subject: Re: /etc/profile.d/lilypond-profile.sh and basename
Message-ID: <20050310142202.GA16211@gully.casa.cgf.cx>
Reply-To: cygwin AT cygwin DOT com
References: <B744015F9200AA49B4E03549EED88B98A27127 AT SCHMLVEM01 DOT e2k DOT ad DOT ge DOT com>
Mime-Version: 1.0
In-Reply-To: <B744015F9200AA49B4E03549EED88B98A27127@SCHMLVEM01.e2k.ad.ge.com>
User-Agent: Mutt/1.5.6i

On Thu, Mar 10, 2005 at 09:11:15AM -0500, Wheeler, Frederick W (Research) wrote:
>In Cygwin, when I ssh to my machine, I get the following error from basename
>
>% ssh d1
>Last login: Thu Mar 10 08:54:40 2005 from caleb.crd.ge.com
>basename: invalid option -- b
>Try `basename --help' for more information.
>-bash: [: too many arguments
>% 
>
>I've traced this into /etc/profile.d/lilypond-profile.sh.  On line 25 we see
>
>  basename "$0"
>
>which becomes
>
>  basename "-bash"

Hmm.  This is due to running bash as a login shell.  I don't see how this
ever worked.

>and gives the error.  Perhaps this resulted from a change in basename
>behavior in the recent coreutils update?  I'm not sure.
>
>21      echo "Continuing anyway ..."
>22      return 2
>23 fi 24 25 if [ -z "$ZSH_NAME" -a `basename "$0"` = "lilypond-profile"
>] ; then
>26      cat >/dev/stderr <<EOF
>27 28 Error: This script cannot be run in a subshell; it MUST be
>sourced.  29 30
>
>Changing line 25 to this
>
>25 if [ -z "$ZSH_NAME" -a `basename "/$0"` = "lilypond-profile" ] ;
>then
>
>seems to work for me.  Now
>
>basename "/$0"
>
>which becomes
>
>basename "/-bash"
>
>and basename prints "-bash" and everything seems to work OK.  I'm not
>sure what all the implications are though.  For example, if $0 is "",
>then basename "/$0" is basename "/" which produced "/".  That might be
>OK for the purposes of this script.

I think that just adding a -- is a better fix:

if [ -z "$ZSH_NAME" -a `basename -- "$0"` = "lilypond-profile" ] ; the

cgf

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019