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]

Bash scripts may misbehave if SHELLOPTS is exported and 'monitor' is enabled

I have noticed that a few scripts misbehave if SHELLOPTS is exported,
or defined in the environment before bash is first invoked.   (I had
set SHELLOPTS=igncr in the system environment - but I've backed this
out to avoid the problems).  The
problems seem to be caused by incorrect signal handling.

In particular, the current version of 'man' crashes with a strange message:

$ man bash
      Bash  is  an  sh-compatible  command language interpreter that executes
      commands read from the standard input or from a file.  Bash also incor-
      porates useful features from the Korn and C shells (ksh and csh).

      Bash  is  intended  to  be a conformant implementation of the Shell and
      Utilities portion  of  the  IEEE  POSIX  specification  (IEEE  Standard
      1003.1).  Bash can be configured to be POSIX-conformant by default.
[1]+  Stopped(SIGTTIN)        ( cd "/usr/share/man" && ( echo ".pl 1100i"; /usr/
bin/cat '/usr/share/man/man1/bash.1'; echo ".\\\""; echo ".pl \n(nlu+10" ) | /us
r/bin/tbl | /usr/bin/nroff -Tlatin1 -mandoc | /usr/bin/less -isrR )
Error executing formatting or display command.
System command (cd "/usr/share/man" && (echo ".pl 1100i"; /usr/bin/cat '/usr/sha
re/man/man1/bash.1'; echo ".\\\""; echo ".pl \n(nlu+10") | /usr/bin/tbl | /usr/b
in/nroff -Tlatin1 -mandoc | /usr/bin/less -isrR) exited with status 38144.
No manual entry for bash

(I tested this on a fresh installation of the Cygwin base packages, so
I'm reasonably
sure that other people will be able to reproduce it!  I've reproduced
it on two machines, both running Windows XP Professional.  Note that I
have to type 'stty sane' to restore normal terminal operation after
the bug has occurred.)

It turned out that the problem has something to do with the 'monitor'
option being enabled.  Normally it would be turned off in
noninteractive scripts, but if SHELLOPTS is in the environment the
setting (turned on by interactive shells) gets propagated to all

The bug disappears if:

1. I keep SHELLOPTS out of the environment, or

2. I change /bin/nroff to use /bin/ash instead of /bin/bash, or

3. I disable the monitor option (set +o monitor) before invoking man

Unsubscribe info:
Problem reports:

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