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


Groups > gnu.bash.bug > #15221

Comment before 'else' on CLI, does not save to history correctly

Path csiph.com!xmission!news.snarked.org!news.linkpendium.com!news.linkpendium.com!panix!usenet.stanford.edu!not-for-mail
From Anthony Thyssen <a.thyssen@griffith.edu.au>
Newsgroups gnu.bash.bug
Subject Comment before 'else' on CLI, does not save to history correctly
Date Wed, 24 Jul 2019 01:16:09 +0000
Lines 48
Approved bug-bash@gnu.org
Message-ID <mailman.2123.1563931148.2688.bug-bash@gnu.org> (permalink)
References <SYXPR01MB0718DC9728D93D7FBE3A9538B2C60@SYXPR01MB0718.ausprd01.prod.outlook.com>
NNTP-Posting-Host lists.gnu.org
Mime-Version 1.0
Content-Type text/plain; charset=WINDOWS-1252
Content-Transfer-Encoding quoted-printable
X-Trace usenet.stanford.edu 1563931149 4938 209.51.188.17 (24 Jul 2019 01:19:09 GMT)
X-Complaints-To action@cs.stanford.edu
To "bug-bash@gnu.org" <bug-bash@gnu.org>
Envelope-to bug-bash@gnu.org
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=griffith.edu.au; s=mimecast20171102; t=1563931057; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type; bh=zplMmvsUutYxbfl6piKcgArW4AP4nB2pBD4bqCCHbKw=; b=hxrhbqlfmwof/4IvXLZ1uwa0frXDDdjwOw+WHECbnpXUURQ3u6nsa3L1HyqD/bHD++HeUS RinhIwzqU0MBQ3Pa9MN6ghkkO8yOq+Hou5unZRLaadJ+8X9517XV9A+7AFlmXUIgR9d/zM TyEJmaHy+RlEEF4EYPTzz1N4Xhrx2j0=
Thread-Topic Comment before 'else' on CLI, does not save to history correctly
Thread-Index AQHVQb1NJK2YI+vIOEiPYQ1MdsHmZQ==
Accept-Language en-AU, en-US
Content-Language en-AU
X-MS-Has-Attach
X-MS-TNEF-Correlator
x-originating-ip [132.234.205.38]
x-ms-publictraffictype Email
x-ms-office365-filtering-correlation-id 6eb945dd-9d64-4a1f-65f8-08d70fd482df
x-microsoft-antispam BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600148)(711020)(4605104)(1401327)(2017052603328)(7193020); SRVR:SYXPR01MB1616;
x-ms-traffictypediagnostic SYXPR01MB1616:
x-microsoft-antispam-prvs <SYXPR01MB1616FAC9B758204DEB143C2BB2C60@SYXPR01MB1616.ausprd01.prod.outlook.com>
x-ms-oob-tlc-oobclassifiers OLM:8273;
x-forefront-prvs 0108A997B2
x-forefront-antispam-report SFV:NSPM; SFS:(10019020)(346002)(396003)(39860400002)(376002)(366004)(136003)(189003)(199004)(88552002)(5660300002)(66476007)(66946007)(66556008)(54896002)(102836004)(5640700003)(6306002)(14454004)(6506007)(6116002)(71190400001)(26005)(8936002)(76116006)(53336002)(3846002)(71200400001)(256004)(6606003)(14444005)(186003)(2501003)(6916009)(66446008)(786003)(81156014)(55016002)(53376002)(81166006)(316002)(64756008)(7696005)(68736007)(53936002)(25786009)(8676002)(7736002)(2906002)(74316002)(476003)(2351001)(33656002)(486006)(478600001)(6436002)(66066001)(9686003)(99286004)(86362001)(19627405001)(52536014)(2004002); DIR:OUT; SFP:1102; SCL:1; SRVR:SYXPR01MB1616; H:SYXPR01MB0718.ausprd01.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A:1;
x-ms-exchange-senderadcheck 1
x-microsoft-antispam-message-info X4HYL18GPVtFDECI43sClxw5Dmpd3AAzRRPwmOPVUNOja7x3y99aOJwmPqKkztXoXtS4jsvw378EO/6clrbhhBcbgtLOpLGm75TttFMQ0A6vUc+Bj9+XuGGjcy9TgDzhflpl9WJ3ccd+LmNmRYe+HOifa4ne3fYiBTWwzeiA3w7O56b4CbId08nKAni+fNWL/72HFaL5/fUXuCXVqAwtrT2xbaSF8cWI2xRT/vpJE6Ohs4sabIeqyswhQG+mxIh6yMYyG2D8s0c6UfiCIHNTgRjtN8gPqkOUDccioVLtYPBlCkQDpFEHD53WEQ2Ry1ZamEQCclRA8W+67xExMUvaePHaMSFiXYr/LQeKRyD1sanN1WYwMQlbgDLJD0CWUn4qnbfAp5Y7s7lvOFFCe2djHksBdA3lCyEazV3QkLxI1UU=
X-OriginatorOrg griffith.edu.au
X-MS-Exchange-CrossTenant-Network-Message-Id 6eb945dd-9d64-4a1f-65f8-08d70fd482df
X-MS-Exchange-CrossTenant-originalarrivaltime 24 Jul 2019 01:16:09.8527 (UTC)
X-MS-Exchange-CrossTenant-fromentityheader Hosted
X-MS-Exchange-CrossTenant-id 5a7cc8ab-a4dc-4f9b-bf60-66714049ad62
X-MS-Exchange-CrossTenant-mailboxtype HOSTED
X-MS-Exchange-CrossTenant-userprincipalname a.thyssen@griffith.edu.au
X-MS-Exchange-Transport-CrossTenantHeadersStamped SYXPR01MB1616
X-MC-Unique tmSsSiXkOFiE8_0xStWPrw-1
X-Mimecast-Spam-Score 0
X-detected-operating-system by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic]
X-Received-From 180.189.28.112
X-Mailman-Approved-At Tue, 23 Jul 2019 21:19:07 -0400
X-Content-Filtered-By Mailman/MimeDel 2.1.23
X-BeenThere bug-bash@gnu.org
X-Mailman-Version 2.1.23
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 <https://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>
X-Mailman-Original-Message-ID <SYXPR01MB0718DC9728D93D7FBE3A9538B2C60@SYXPR01MB0718.ausprd01.prod.outlook.com>
Xref csiph.com gnu.bash.bug:15221

Show key headers only | View raw


Version:  bash --version
GNU bash, version 4.4.23(1)-release (x86_64-redhat-linux-gnu)
Copyright (C) 2016 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>

This is free software; you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

OS:  Fedora 28,  Running on a Dell Latitude E7450
Standard RPM Package: bash-4.4.23-1.fc28.x86_64


if you type a multi-line if-then-else-fi  statement with a command before the else.
Bash does not add a semi-colon before the else when saving to history.

Type into command line (watch out for no-break-spaces added by mail)...


if true
then echo yes
# comment - required to activate bug
else echo no
fi

this works fine!  outputting "yes"
But if you look at the history

history|grep i\\f|tail -1

Returning...

  830  if true; then echo "yes" else echo "no"; fi

You will see the required ';' before the else is missing.
Meaning if the command is repeated from history it will go wrong.
Producing instead...

yes else echo no

If the comment was not present, the semicolon is added correctly.
Probably effects other muti-line input containing comments too.

Anthony Thyssen,  writing shell script since 1988


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


Thread

Comment before 'else' on CLI, does not save to history correctly Anthony Thyssen <a.thyssen@griffith.edu.au> - 2019-07-24 01:16 +0000

csiph-web