I am writing some Unix scripts on Mac OS X that use
sqlite3. Since the program could be useful to those
on Windows, I figured I'd see if they worked under
cygwin.

A lot of it works, but calling sqlite3.exe from
cygwin and returning a string with the value
returned from the database seems to attach a
"\r" that expr doesn't remove.

That is:

NumPar=`sqlite3.exe ${DATABASE} "SELECT NumPar FROM citations WHERE 
X='Key' ;"`

NumPar comes back as: "12\r"

and

NumPar=`expr ${NumPar}`

doesn't convert it to integer, as the subsequent test fails because
of NumPar being non-integer (it isn't complaining about N, that
is integer in the code):

if [ ${N} -le ${NumPar} ]
...

I can fix this case by:

NumPar=`printf '%s' "${NumPar}" | sed 's/[^0-9]//g'`

but then other scripts fail later, presumably because of
strings with \r on them. (I suppose I can use sed to
always remove \r's on every one of these calls, but
that seems pretty kludgy, especially since "clean"
Mac OS X handles all this "properly" without that.
I'm hoping to find an elegant solution.

I'd rather avoid building sqlite3 under cygwin. I would like
to keep as much as possible in native code, compromising only
on cygwin to run my scripts.

When installing cygwin, you it offers you the choice to switch
to default text file type to DOS (\r\n). Should I try that?
My pretty serious objection to that would be that any users
already using cygwin with the "correct" default settings would
not be able to use the scripts anyway.

So I guess my question here is, do any sqlite users here
have experience fixing this on Windows for Unix cygwin
script calls?

Thanks!
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to