Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > gnu.bash.bug > #14623

Re: Special parameter ?

Path csiph.com!xmission!news.snarked.org!news.linkpendium.com!news.linkpendium.com!panix!usenet.stanford.edu!not-for-mail
From Eduardo A. Bustamante López <dualbus@gmail.com>
Newsgroups gnu.bash.bug
Subject Re: Special parameter ?
Date Fri, 21 Sep 2018 08:17:33 -0700
Lines 28
Approved bug-bash@gnu.org
Message-ID <mailman.1091.1537543061.1284.bug-bash@gnu.org> (permalink)
References <201809211123.w8LBNvHe018414@omac.gsyc.urjc.es> <20180921125705.646znyglxhb6rqga@eeg.ccf.org> <CAMPpeEWtyF=PKPYORSwVAPWVxLj85LDvz=bhth9JUR6q+YuzjQ@mail.gmail.com>
NNTP-Posting-Host lists.gnu.org
Mime-Version 1.0
Content-Type text/plain; charset=us-ascii
X-Trace usenet.stanford.edu 1537543062 9707 208.118.235.17 (21 Sep 2018 15:17:42 GMT)
X-Complaints-To action@cs.stanford.edu
Cc bug-bash@gnu.org, bash@packages.debian.org
To Enrique Soriano <esoriano@gsyc.urjc.es>
Envelope-to bug-bash@gnu.org
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:mail-followup-to:references :mime-version:content-disposition:in-reply-to:user-agent; bh=+2yQUaO/su5CxE0EpI5gFr/+r3Bm9Izp2fd6ANGjNAw=; b=MhB1/7EWZ4K9QznD7cSP6Wkmqsjh8o8G/uD+Ij2A0b2kdZsKmxUviGL6jl11wJRYHG pVzlylSehMztRDEXzRYJid3XfjDAzrtCUCwy+Rcgu/VSiIDbLMtUsCSqgI0HBVx2G2Ff bymBrzdXQQs6vQpGZycHMf1OH0rC4zV6Y1Gfj7G+xRA76Muy63uhoO43b7nDMOIivfmL vZw6PF7qwNj5vOf+dBYURchqOQ+XulMDQYUfX8hTODecna4s7H+U80TZXutULDMEG5dF Feb2CwmWrHpGeG25N4eIGdJRnyEh/jv1BoRGsif+z7yiiKFTxM/qEW6nT+qC2HKaBbzv EaLQ==
X-Google-DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id :mail-followup-to:references:mime-version:content-disposition :in-reply-to:user-agent; bh=+2yQUaO/su5CxE0EpI5gFr/+r3Bm9Izp2fd6ANGjNAw=; b=rgr8KC4eSAz/hZkPzy5X4KL+SMFFeH4tmBBnUfZqClalt85eadEgdmHm964HuP0M6d AArG+Jl2KXVgt8knS9VCsXQlc8uYWBw8LFHNpbUVPw4PDDXrRxOaxtoBM5qGcMPBstPn T1DRCJ0745+kjO9FibNlMg4hDEh7JkLrh7t0uU/zGJF8SO5tLR3n3KUabbLO8V9CveGs 9B0lsbtNsstQMSpAf/KtkkZc02JfXz+ggKvB+qx5d9+KkoMPq0wa1vbMYZwXEmk4Mdrz vooZshNFTm/Z1nwCiXT7dyk4mZVFn1lq/u70eXp6BJCcuFxPc0qlYXJM/MIzqURCn3bO 8hhg==
X-Gm-Message-State APzg51CJDZwzIrx+Wd4LNksgi6OgX2HAQzkDTQRst1LRwnpjSxlaSBz7 9ydRO6LeL9zXw7UHEKFS2+A=
X-Google-Smtp-Source ANB0VdYKw802c24wF5vWRIlFlrq3kXepVYdnQISTtY/hWfJoLJRf3ToDW2mk37BrPWqST/oIG9kypQ==
X-Received by 2002:a62:280a:: with SMTP id o10-v6mr46811638pfo.129.1537543056294; Fri, 21 Sep 2018 08:17:36 -0700 (PDT)
Mail-Followup-To Enrique Soriano <esoriano@gsyc.urjc.es>, bug-bash@gnu.org, bash@packages.debian.org
Content-Disposition inline
In-Reply-To <CAMPpeEWtyF=PKPYORSwVAPWVxLj85LDvz=bhth9JUR6q+YuzjQ@mail.gmail.com>
User-Agent Mutt/1.10.1 (2018-07-13)
X-detected-operating-system by eggs.gnu.org: Genre and OS details not recognized.
X-Received-From 2607:f8b0:4864:20::441
X-BeenThere bug-bash@gnu.org
X-Mailman-Version 2.1.21
Precedence list
List-Id Bug reports for the GNU Bourne Again SHell <bug-bash.gnu.org>
List-Unsubscribe <https://lists.gnu.org/mailman/options/bug-bash>, <mailto:bug-bash-request@gnu.org?subject=unsubscribe>
List-Archive <http://lists.gnu.org/archive/html/bug-bash/>
List-Post <mailto:bug-bash@gnu.org>
List-Help <mailto:bug-bash-request@gnu.org?subject=help>
List-Subscribe <https://lists.gnu.org/mailman/listinfo/bug-bash>, <mailto:bug-bash-request@gnu.org?subject=subscribe>
Xref csiph.com gnu.bash.bug:14623

Show key headers only | View raw


On Fri, Sep 21, 2018 at 04:17:11PM +0200, Enrique Soriano wrote:
> > You're seeing the status from the creation of the background job (which is
> > always 0), not from its completion.
> 
> Ah, I see.
> 
> Anyway, the behavior is not coherent with the manual page: in this
> case, $? has the status from the creation of the background job,
> that's not "the status of the most recently executed foreground
> pipeline".

The thing that creates the background job IS a foreground pipeline. It's a foreground pipeline that creates a background
job, if that makes sense.

dualbus@ubuntu:~$ cat t.sh
(exit 2)
(exit 3) & pid=$!
echo $?
wait "$pid"
echo $?

dualbus@ubuntu:~$ bash t.sh
0
3

I recommend to store the value of $? in a variable if you plan on using it afterwards, since it's extremely easy to end
up overriding its value.

Back to gnu.bash.bug | Previous | Next | Find similar | Unroll thread


Thread

Re: Special parameter ? Eduardo A. Bustamante López <dualbus@gmail.com> - 2018-09-21 08:17 -0700

csiph-web