www.delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2008/03/13/07:14:58

X-Recipient: archive-cygwin AT delorie DOT com
X-Spam-Check-By: sourceware.org
X-Authority-Analysis: v=1.0 c=1 a=xe8BsctaAAAA:8 a=tPMkxCp-Ni3THP6xwEgA:9 a=2nNc_rw8RmuZopGAPdQA:7 a=2Fb2OpSWyaaspJr8HDvXCDCSQdIA:4 a=eDFNAWYWrCwA:10 a=rPt6xJ-oxjAA:10
Message-ID: <47D91A8B.2040500@byu.net>
Date: Thu, 13 Mar 2008 06:14:03 -0600
From: Eric Blake <ebb9 AT byu DOT net>
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.12) Gecko/20080213 Thunderbird/2.0.0.12 Mnenhy/0.7.5.666
MIME-Version: 1.0
To: cygwin AT cygwin DOT com
Subject: Re: On Bash options
References: <47D9023A DOT 7050803 AT alice DOT it>
In-Reply-To: <47D9023A.7050803@alice.it>
X-IsSubscribed: yes
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Id: <cygwin.cygwin.com>
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

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

According to Angelo Graziosi on 3/13/2008 4:30 AM:
| 'start_urxvt.sh' contains at the end:
|
| [...]
| exec /usr/bin/urxvt

Why execute bash, just to exec urxvt, which in turn executes another
instance of bash?  Why not just put urxvt as the shortcut target instead,
using ~/.Xdefaults to control everything rather than needing bash to set
it up?

|
| which starts an URXVT console.
|
| Well, the fact is that its prompt is:
|
| sh-3.2$

That's because urxvt, when given no -e option for which shell to spawn,
defaults to $SHELL then /bin/sh.  Bash, when invoked as /bin/sh, doesn't
source the same set of startup files.  Your first invocation of bash,
using -c, is not interactive and thus does not set SHELL, so urxvt is
forced to start /bin/sh, explaining the different prompt.

|
| If I change the above link using the '-e' instead of '-c' option,
|
| C:\cygwin\bin\run.exe bash -l -e start_urxvt.sh

Bash accepts as options all of the single-character options to 'set'.
'set -e' asks bash to exit immediately on the first simple command that
returns non-zero status.  Generally not what you want for an interactive
shell session - however, as long as your start-urxvt.sh script has no
simple commands that fail, you won't notice the difference, because the
shell you get in the urxvt window was not started with -e.

|
| then the prompt is the one I like, i.e.
|
| angelo AT mypc ~
| $

Here, the first invocation of bash is still running (whereas before, it
exited completely in favor of urxvt).  But it is interactive, so it sets
SHELL, thus urxvt starts another instance of bash under the same name as
the first bash rather than falling back to /bin/sh, thus explaining the
difference in the prompt.

|
| I have searched the description of '-e' option using 'man bash' but I
| have not found it. (I have also searched the string '-e' in bash.1, but
| without success)

You didn't search hard enough.  Read the first sentence after OPTIONS.
Then search for the description of set.  It's all in the bash manpage.

|
| Is there a bug in bash.1 or what else?

No bug.  Nor is this question cygwin specific (other than the fact that
you used a shortcut to launch bash rather than urxvt).

- --
Don't work too hard, make some time for fun as well!

Eric Blake             ebb9 AT byu DOT net
volunteer cygwin bash maintainer
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.8 (Cygwin)
Comment: Public key at home.comcast.net/~ericblake/eblake.gpg
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAkfZGooACgkQ84KuGfSFAYBZhwCgjR2yqznyF4Zi7OKzQebogtOW
qrMAn0Jls9VbP2uN7pWPWpkGJbbmS+/T
=2MJD
-----END PGP SIGNATURE-----

--
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