Path: csiph.com!xmission!news.snarked.org!news.linkpendium.com!news.linkpendium.com!panix!usenet.stanford.edu!not-for-mail From: "Dr. Werner Fink" Newsgroups: gnu.bash.bug Subject: Re: [bug-bash] Which commit for a bug in 4.3.48 which is fixed in 4.4.23 Date: Mon, 24 Sep 2018 13:09:01 +0200 Lines: 167 Approved: bug-bash@gnu.org Message-ID: References: <20180921111138.GA24148@boole.suse.de> NNTP-Posting-Host: lists.gnu.org Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="dc+cDN39EJAMEtIO" X-Trace: usenet.stanford.edu 1537787355 20280 208.118.235.17 (24 Sep 2018 11:09:15 GMT) X-Complaints-To: action@cs.stanford.edu To: bug-bash@gnu.org Envelope-to: bug-bash@gnu.org X-Virus-Scanned: by amavisd-new at test-mx.suse.de Content-Disposition: inline In-Reply-To: <20180921111138.GA24148@boole.suse.de> X-GPG-Fingerprint: 1B06 BF5A 3829 90FB CBA2 75BE 50E9 0D55 1DC1 6B2E User-Agent: Mutt/1.10.1 (2018-07-13) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x (no timestamps) [generic] X-Received-From: 195.135.220.15 X-BeenThere: bug-bash@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Bug reports for the GNU Bourne Again SHell List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Xref: csiph.com gnu.bash.bug:14651 --dc+cDN39EJAMEtIO Content-Type: multipart/mixed; boundary="n8g4imXOkfNTN/H1" Content-Disposition: inline --n8g4imXOkfNTN/H1 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Fri, Sep 21, 2018 at 01:11:38PM +0200, Dr. Werner Fink wrote: > Hi, >=20 > with 4.3.48 the line >=20 > T=3D"";echo ">${T//*/ }<" >=20 > leads to >=20 > >< >=20 > but with 4.4.23 the correct result is given back >=20 > > < >=20 > in the git repro I do not find any useful login entry for this Reconstructed the attached patch ... seems to work --=20 "Having a smoking section in a restaurant is like having a peeing section in a swimming pool." -- Edward Burr --n8g4imXOkfNTN/H1 Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="bash-4.4-boo1107430.dif" Content-Transfer-Encoding: quoted-printable Fix `*' matches any string, including the null string as e.g. T=3D"" echo ">${T//*/ }<" had not worked,, that is return string "> <" --- lib/glob/gmisc.c | 4 ++-- subst.c | 20 +++++++++++++++++--- 2 files changed, 19 insertions(+), 5 deletions(-) --- subst.c +++ subst.c 2018-09-24 10:46:21.913346656 +0000 @@ -4396,7 +4396,7 @@ match_pattern (string, pat, mtype, sp, e size_t slen, plen, mslen, mplen; #endif =20 - if (string =3D=3D 0 || *string =3D=3D 0 || pat =3D=3D 0 || *pat =3D=3D 0) + if (string =3D=3D 0 || pat =3D=3D 0 || *pat =3D=3D 0) return (0); =20 #if defined (HANDLE_MULTIBYTE) @@ -6453,6 +6453,7 @@ get_var_and_type (varname, value, ind, q { if (value && vtype =3D=3D VT_VARIABLE) { + *varp =3D find_variable (vname); if (quoted & (Q_DOUBLE_QUOTES|Q_HERE_DOCUMENT)) *valp =3D dequote_string (value); else @@ -6642,6 +6643,8 @@ pat_subst (string, pat, rep, mflags) * with REP and return the result. * 2. A null pattern with mtype =3D=3D MATCH_END means to append REP to * STRING and return the result. + * 3. A null STRING with a matching pattern means to append REP to + * STRING and return the result. * These don't understand or process `&' in the replacement string. */ if ((pat =3D=3D 0 || *pat =3D=3D 0) && (mtype =3D=3D MATCH_BEG || mtype = =3D=3D MATCH_END)) @@ -6663,17 +6666,27 @@ pat_subst (string, pat, rep, mflags) } return (ret); } + else if (*string =3D=3D 0 && (match_pattern (string, pat, mtype, &s, &e)= !=3D 0)) + { + replen =3D STRLEN (rep); + ret =3D (char *)xmalloc (replen + 1); + if (replen =3D=3D 0) + ret[0] =3D '\0'; + else + strcpy (ret, rep); + return (ret); + } =20 ret =3D (char *)xmalloc (rsize =3D 64); ret[0] =3D '\0'; =20 - for (replen =3D STRLEN (rep), rptr =3D 0, str =3D string;;) + for (replen =3D STRLEN (rep), rptr =3D 0, str =3D string; *str;) { if (match_pattern (str, pat, mtype, &s, &e) =3D=3D 0) break; l =3D s - str; =20 - if (rxpand) + if (rep && rxpand) { int x; mlen =3D e - s; @@ -6682,6 +6695,7 @@ pat_subst (string, pat, rep, mflags) mstr[x] =3D s[x]; mstr[mlen] =3D '\0'; rstr =3D strcreplace (rep, '&', mstr, 0); + free (mstr); rslen =3D strlen (rstr); } else --- lib/glob/gmisc.c +++ lib/glob/gmisc.c 2018-09-24 10:46:30.673185840 +0000 @@ -53,7 +53,7 @@ match_pattern_wchar (wpat, wstring) wchar_t wc; =20 if (*wstring =3D=3D 0) - return (0); + return (*wpat =3D=3D L'*'); /* XXX - allow only * to match empty strin= g */ =20 switch (wc =3D *wpat++) { @@ -230,7 +230,7 @@ match_pattern_char (pat, string) char c; =20 if (*string =3D=3D 0) - return (0); + return (*pat =3D=3D '*'); /* XXX - allow only * to match empty string = */ =20 switch (c =3D *pat++) { --n8g4imXOkfNTN/H1-- --dc+cDN39EJAMEtIO Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQJgBAABCABKFiEEGwa/WjgpkPvLonW+UOkNVR3Bay4FAluoxcksFIAAAAAAFQAO cGthLWFkZHJlc3NAZ251cGcub3Jnd2VybmVyQHN1c2UuZGUACgkQUOkNVR3Bay5a vQ/+MRW7fLKtwybQDlmVMxLhfIBY0R0930m2HB4UCJRILMNqcmirFl38i56j7WLf X6TDKfvriEDtFvcaRxiXERwml1Mev6RDK8acSHAjOHrtdviPFXdEGet9OZa0/Yrz APuHhJZ53YoENMxzPvb3hYo/w/uTOCKrZM/G0O1nx/l+rQvcqeDb2URGJC1d4FKH T+gQKn9a/8RRGLGDPM61QHyUJSynIEKF+Hpx0J2rvPEl7QyYEwczvckiQ9x5WuOy y9sregysSzxaR4nMmWXOEFkS+PV741f25ysSUOfFAbFYRXzMKckBd896G++gIQC8 HokqskrF8GdeKzFqnn/xFtifZlXwXOZxd0jxN+LKOO+5qfz8DIGURmBI4/c22dge 9H45VRw2kyFukJBPOLMSUk4iI/7bcGjLlcjXaiGSlxgptJr9Sii7EGgtzDWWh+ZQ Bk5/Rb4ALKdBvErAywyeBzcXPt5i6sUHf/5cAquidKGt0VQHwwpSVLCfn11u0EiZ RQPk29wQdE+f7bz2nv/jYIZFj5uxU9EbJd8RodVCPMuKQM26LdHbXQX6IKjI4GHr Cr59XVVxLUw5JljFFAgu4NgHQWVZasja10y0vSQg1ecyIt+ieHFHDyornmOAsR/G fGCZQ3QMiqgja4AajtYcXS5p9/Jo/eGdUWl9WMp69oflUMo= =P6EI -----END PGP SIGNATURE----- --dc+cDN39EJAMEtIO--