This is the mail archive of the cygwin mailing list for the Cygwin project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

bash: igncr shell option breaks my PS1 prompt

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
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.


Problem reports:
Unsubscribe info:

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]