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

Hash: SHA1

According to Angelo Graziosi on 3/13/2008 4:30 AM:
| '' 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

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 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   
volunteer cygwin bash maintainer
Version: GnuPG v1.4.8 (Cygwin)
Comment: Public key at
Comment: Using GnuPG with Mozilla -


Unsubscribe info:
Problem reports:

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