This is the mail archive of the cygwin mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: On Bash options


-----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@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@byu.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/


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]