Path: csiph.com!optima2.xanadu-bbs.net!xanadu-bbs.net!eternal-september.org!feeder.eternal-september.org!news.glorb.com!usenet.stanford.edu!not-for-mail From: Charles Daffern Newsgroups: gnu.bash.bug Subject: Re: BUG?: (or what's going on?) test for NL == NL fails (bash-4.3.39(3)-release) Date: Sun, 2 Aug 2015 22:15:45 +0100 Lines: 55 Approved: bug-bash@gnu.org Message-ID: References: <55BE6FB8.4080200@tlinx.org> <55BE7DD6.3040509@tlinx.org> NNTP-Posting-Host: lists.gnu.org Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="AKU7iPxA12TwvhQnf0pVlVgtKgoBfvjLt" X-Trace: usenet.stanford.edu 1438550166 13909 208.118.235.17 (2 Aug 2015 21:16:06 GMT) X-Complaints-To: action@cs.stanford.edu To: bug-bash@gnu.org Envelope-to: bug-bash@gnu.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=subject:to:references:from:openpgp:message-id:date:user-agent :mime-version:in-reply-to:content-type; bh=9h7Ph/iXla+WLgsWoULPzgo9XqG67WEIpGQrpud8H/E=; b=u68hPk7rShYELP+5mD7qb6PMyB1Eyi1MPHmWkx3KxefCRwlFJQxN1PBbp+mSzCV6bB MLPbIqsOV2VQnrTcPFav1bx+azQaR3v8jxwaSFeF0VeFUQIKtfP4RHnxC2tDVIpmGDOs AD9YEaPnfYe3xjCKC4US394rkQKOQJgEU4yDR9RX28ZRYBnDjMwvprom91gClvIxdWvW E1PiQFc5VFPlbKpejbmZp+6wf600RgZx3HXbEpmFRKjbr/l6Rvph9tYFjFDSqXIH5ytn mBcgaog0Z+BV4KSk4BYaYNHE2A1353u+UlVfRnHMmvKMJxJVR6Vg1w2hTAcbGUejKWbH nZaw== X-Received: by 10.180.8.68 with SMTP id p4mr27812852wia.27.1438550159674; Sun, 02 Aug 2015 14:15:59 -0700 (PDT) Openpgp: id=AF6C170E59E8276568DD539A2B02A98D99BB3683; url=https://keybase.io/score_under User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.0.1 In-Reply-To: <55BE7DD6.3040509@tlinx.org> X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2a00:1450:400c:c05::22b X-BeenThere: bug-bash@gnu.org X-Mailman-Version: 2.1.14 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:11283 This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --AKU7iPxA12TwvhQnf0pVlVgtKgoBfvjLt Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 02/08/15 21:30, Linda Walsh wrote: > Am just looking for an efficient way to test for 0x0a > as last char in a var, ... after another 20 minutes of > trying things at random, found this: > > > printf "%d\n" "'${a:0-1:1}'" > 10 > > Oddly, the final single quote in the string seems unnecessary. > But that (or into a var: printf -v var) both work...but I > feel a bit contorted trying so many odd ways to get something > that I thought would be simple, to work. Most of the problems here are due to the use of command substitution (as I mentioned in an earlier response). The ways I would go about checking for a newline at the end of a string a= re: [ "$var" !=3D "${var%$'\n'}" ] or [[ $var =3D *$'\n' ]] --AKU7iPxA12TwvhQnf0pVlVgtKgoBfvjLt Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQIcBAEBCAAGBQJVvoiCAAoJECsCqY2ZuzaDgW4P/0CmpzykWoqJJPSi5eWDYgGG 6+83wYfHnr2rudySuCBFIEHjoofI45axluTzwZU7r7MYzdN7uz1Whz7hoCWGDvgx 9e7T9VDlJnHVlZAhswEnOFV1E56r5Exnr2UxebTSdtYfBF1mqmoS+/wYowPN3h2a Gukxdq+GBpakKlqdN+sOQ1pj/11jsFblR1RIwg9T7Lk1QyxdmuK9HDSRG2dDF59W wnQwcvHulJ1MR0DPY0Gzm2bWEKxLGkxgwtmT9KofpRSUh/ssMpXxYXUt3kuWyBE7 rfsmCzdWkMhBXcY/BueGd00CVtoDjNTkF/rZKMLl3Dvs53Kid99sAQpXJ2w9agWt L28IZDjbcJPKEkvAe8lF3WlfRLS1dkXv2YmlCR3jNPQgrhI+JGjpZaazSEWYT+Ht ozerEBQ9f6tkq2e7ZoePGFKZdPBxNQsbgLrUb3yj8ehviEkLr9O1YeZexLJL1bFj 1Nu/G816ZsvP40qfJVhVwPkXbJK4GV/JiyMNresb9RqlrQf3sS4FvF1+g7sQYQq4 R+YOFKmLpLZQMV6PxBkEkVMcd/vmuDbo5V25u79ZZt5dmnF8Yq6MgQ5ABmo7hdxj OZyxiye2KTtElovqH1WrE8TKN83zYhHpoS/mcRQIpfwJ6L0nRaoL2BuemRfKqPJM 6qVPYxO7mG6baxXWLPT4 =+GgM -----END PGP SIGNATURE----- --AKU7iPxA12TwvhQnf0pVlVgtKgoBfvjLt--