www.delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2017/08/30/19:27:05

X-Recipient: archive-cygwin AT delorie DOT com
DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id
:list-unsubscribe:list-subscribe:list-archive:list-post
:list-help:sender:from:to:subject:date:message-id:mime-version
:content-type:content-transfer-encoding; q=dns; s=default; b=YUA
2zXCOdKd2mN8nR1ubgVXXHlYZpgiiTkcozsFACsExflVdOOjbKHCt5Wand0Mb2y0
xa58kKegf1VCRSpWMTCRu5F8JoSadbcI7MqUX6H1LvQs6Sw5WEFakx4NSzNmMSKn
qfErGxfNuRzCNITgel59FcrJ/P6zPQpXuzM3uBLE=
DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id
:list-unsubscribe:list-subscribe:list-archive:list-post
:list-help:sender:from:to:subject:date:message-id:mime-version
:content-type:content-transfer-encoding; s=default; bh=4IZTTdY8F
9Que9JD4XKlycOMxhA=; b=DrgqkRckoZr4RbhspDtlZj3y68EgNpphq8YXGYgOh
OZ/5/L2YHUoNNKBZ90fykMgve6XVyiIGKoGQfztbmELAYxDf9d2ldvYmNMbz8dpE
ZtplFahRj00AC5gXbGn5f3Gm+nlGb29ojpiYJalUuBZP3QimwPKIPeUg1F1MCQD0
Bs=
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
Authentication-Results: sourceware.org; auth=none
X-Virus-Found: No
X-Spam-SWARE-Status: No, score=-0.1 required=5.0 tests=AWL,BAYES_40,RCVD_IN_DNSWL_LOW autolearn=ham version=3.3.2 spammy=H*r:NNFMP, HX-Yahoo-Newman-Property:ymail-3, H*F:D*rogers.com, H*M:rogers
X-HELO: nm22-vm8.access.bullet.mail.gq1.yahoo.com
X-Yahoo-SMTP: _oUbE.SswBCQ_d_LvSIk7sZfv6R7Is8n9OVRVjJJh3dhqEgGPCs-
From: "Michel LaBarre" <michel DOT labarre AT rogers DOT com>
To: <cygwin AT cygwin DOT com>
Subject: Bash monitor mode remains enabled if disabled in .bashrc
Date: Wed, 30 Aug 2017 19:26:38 -0400
Message-ID: <000701d321e7$6ed52220$4c7f6660$@rogers.com>
MIME-Version: 1.0
X-IsSubscribed: yes

Playing with set -m/+m and shopt -s lastpipe, in an interactive bash shell,
I came across a situation 
which is minor unless  it has broader implications for others that I do not
know about.

Specifically if "set +m" is present in  .bashrc, it looks like job control
(monitor mode) is off 
in an interactive shell (as per "echo $-") but it is actually on.

I ran into this with "shopt -s lastpipe" behaviour with and without job
control.
I can also reproduce it with "sleep 25&" then "fg" will fail with "no job
control".

If I "set +m" within the interactive shell rather than, or in addition to,
.bashrc, both the 
flags ($-) and behaviour (lastpipe and fg) reflect job control being off.

I include only an example with lastpipe.

FYI - from bash reference for shopt:
lastpipe If set, and job control is not active, the shell runs the last
command
	of a pipeline not executed in the background in the current shell
	environment.

My .bashrc includes "shopt -s lastpipe" and "set +m".  
My objective was to produce the same conditions as within a script for
debugging a messy statement at a command line
and I had no need for job control while doing this and I would sometimes
forget to disable monitor mode after a new bash.
If somebody trying to debug some bash statements and is unaware that a
second "set +m" is required, they
might be confused for a bit.  (An option to make an interactive shell behave
the same as a non-interactive shell
might facilitate such debugging.)

C:\mybin>bash
$ echo "$-"                       # no "m" meaning monitor mode is off i.e.
no job control...
hiBHs
$ echo abc | read zot     # zot is therefore in a sub-process hence value
not available in this process
$ echo $zot

$ set +m                
$ echo "$-"                        # still no m but behaviour is
different...
hiBHs
$ echo abc | read zot    # read zot now running in this process so value is
available
$ echo $zot
abc
$ bash --version
GNU bash, version 4.4.12(3)-release (x86_64-unknown-cygwin)

By the way, the "s" set option ($- above) is not defined in the bash
reference manual that I have and is not accepted 
by the "set" built into bash so I don't know how it gets set.  (i.e."set -s
s" or "set +s s" both fail with "invalid option".)

Michel LaBarre





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

- Raw text -


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