From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 89650 invoked by alias); 27 Aug 2016 11:40:55 -0000 Mailing-List: contact cygwin-help@cygwin.com; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner@cygwin.com Mail-Followup-To: cygwin@cygwin.com Received: (qmail 89640 invoked by uid 89); 27 Aug 2016 11:40:54 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.5 required=5.0 tests=AWL,BAYES_00,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,SPF_PASS autolearn=ham version=3.3.2 spammy=guy, surprising X-HELO: mail-it0-f47.google.com Received: from mail-it0-f47.google.com (HELO mail-it0-f47.google.com) (209.85.214.47) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sat, 27 Aug 2016 11:40:52 +0000 Received: by mail-it0-f47.google.com with SMTP id e63so8448600ith.1 for ; Sat, 27 Aug 2016 04:40:52 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=fWqUh1X9tTiV6D5iX7bhX0Tzj/s8hVbqrMHWSMjbGoc=; b=ODvycAK8XHVStceLhy63sNIdYMOtkHhjSik75c0bqR36gy/103rpvCVLfzGiv88g8W KhyfFyqBE9A2j2dlLYP5nzM/Dt6iiP+qqWnaggEiBaPrZ+S9qSeA+GsQp9yuZ4vmpZ1K IKJaqK4Y/WGJHZyMHCMNi434+2eeVktEeNGdFwKH48tmarvErZzzC0c2gaErpx/SWdpk RvPycXDwDyl7xcTgvlUKeyu30EQubyRaHwWO7cqLA1I1UHnWYIZnWikzoym9Z03FjHrG 3xLLlzYa2SIvWoDF3Q1kVsSrpkakN4I/t/29n/FNkPgSxQXn675k5GooZVQoPsETuR01 Kguw== X-Gm-Message-State: AE9vXwNjc/90vWYUlzp9rzZ5TnfcK/bP2mgA2epqXKhvuT4e7RBxbPqclllswbkAkKazAam4SZqBPbxIwFrTdw== X-Received: by 10.107.130.81 with SMTP id e78mr10381792iod.137.1472298050914; Sat, 27 Aug 2016 04:40:50 -0700 (PDT) MIME-Version: 1.0 Received: by 10.79.116.26 with HTTP; Sat, 27 Aug 2016 04:40:50 -0700 (PDT) From: Gene Pavlovsky Date: Sat, 27 Aug 2016 16:20:00 -0000 Message-ID: Subject: bash: igncr shell option breaks my PS1 prompt To: cygwin@cygwin.com Content-Type: text/plain; charset=UTF-8 X-IsSubscribed: yes X-SW-Source: 2016-08/txt/msg00549.txt.bz2 Apparently the latest bash in Cygwin modified the read builtin to use Cygwin-specific shell option igncr to control ignoring \r characters in the input (still not clear if that ignores \r\n sequences, or \r followed by anything else will be also ignored). This broke a mysql database backup script I had - specfiically reading output of `show databases` sql command. Since I never used the `igncr` shell option, with the latest bash update the `read` built-in reads the database names with \r at the end. I considered enabling the `igncr` option everywhere, by declaring a SHELLOPTS=igncr Windows environment variable, however immediately it created an issue with my two-line PS1 prompt, which contains \n. # PS1='\e[1;30m\D{%T}\e[m$(test \j -ne 0 && echo " \e[1;37mj:\j\e[m")${STY:+ \e[1;32m${STY%%.*}\e[m} \e[1;33m\w\e[m\n# ' 14:32:22 /usr/local/bin # set -o igncr bash: command substitution: line 1: syntax error near unexpected token `)' bash: command substitution: line 1: `test 0 -ne 0 && echo " j:0")' 14:32:24{STY:+ } /usr/local/bin # set +o igncr 14:32:26 /usr/local/bin # What's wrong with this? It works fine on a Linux box. I'm considering rolling back bash until I can figure this out. I really think it was an unwise move to hastily modify the `read` bash built-in's behavior without a lot of testing. And basically now I should either put Cygwin-specific checks (if cygwin, then set igncr shell option) in all of my scripts that *might* be affected, or be forced to set igncr shell option system-wide, which I'd prefer not to do. Can't imagine I'm the only guy whose scripts might be getting weird problems now. Unless everybody been using `igncr` shell option (off by default) for ages, and I'm the only guy who just heard about that? Personally I don't like the `igncr` option's behavior. I want my bash scripts to fail if somebody saved (or checked out from git) with CRLF line endings. If it happens, I will notice immediately and then fix them. Don't want to have bash scripts with CRLF line endings lurking on my system, pretending to be nice - then one day I'll copy one to my Linux box where it will break, surprising me more than when I first created it or checked out from git. Regards, --Gene -- 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