This simple command fails in bash:
echo "print 'tsql'" | sqlcmd -E
it works correctly in a regular old command prompt.
It used to work with previous versions of cygwin. I've also tried inserting various flavors of unix2dos in there, and I've looked at the output with "od -c". So I'm quite sure it's not just a LF vs. CR/LF problem.
Looking at this thread: http://cygwin.com/ml/cygwin/2010-01/msg00205.html
leads me to believe something got broken in cygwin, but I've been unable to chase down any more leads.
Does anyone have any clues, other than generating a temp file, and then using
sqlcmd -E -i tempfile
which does work, but it's ugly.
Best Answer
I am using MSYS2 (x86-64, installed with the 20150916 and updated using
pacman
to the latest default packages as of two days ago) but I ended up encountering the same error (which makes sense as MSYS2 is a cygwin derivative). I never had this with MSYS, but since MSYS is kind of dead and I wanted more modern tools I am switching to MSYS2 and porting my scripts. I found a workaround that is working for me at the moment:I assume it works because we’re asking
cmd
to set up the pipe between the MSYS2 process (cat
) and the Windows process rather than letting MSYS2/bash
do it. Though I also suspect thatSQLCMD
is doing some evil nasty trickery from Windows programming in the ’90s which it shouldn’t be doing in the first place making it a special case which perhaps deserves a workaround be developed in cygwin/MSYS2.Note that with this method passing arguments to
sqlcmd
becomes really difficult, especially if you want to pass a literal"
.Full output from me demonstrating the error, its solution, and showing where my
sqlcmd
is coming from: