This is the mail archive of the
cygwin
mailing list for the Cygwin project.
Re: Running non-cygwin executables in cygwin bash terminal or script
- From: Andrey Repin <anrdaemon at yandex dot ru>
- To: Kal Sze <swordangel at gmail dot com>, cygwin at cygwin dot com
- Date: Wed, 5 Nov 2014 22:11:33 +0300
- Subject: Re: Running non-cygwin executables in cygwin bash terminal or script
- Authentication-results: sourceware.org; auth=none
- References: <CAGZiy731mOGON-Bhd9XYZo-8jQ0WrLKOioxKBGnJrZbDprGvPg at mail dot gmail dot com>
- Reply-to: cygwin at cygwin dot com
Greetings, Kal Sze!
> In general, is there anything that can go wrong or not work if I
> invoke regular Windows/.NET executables (not compiled with any cygwin
> header or linked with any cygwin dll) from a cygwin bash terminal or
> script?
Speaking veeery-veeery generally, no. A program is a program. If it can be
run, it'll run. (I.e., I'm starting WoW client from shell script.)
However, there's a number of things you should be aware of.
> I am planning to write a bash script to call rsync and then a command
> line program written in C# (.NET framework 4.5 in Visual Studio 2013).
> I'm not a huge cygwin/posix/unix hacker, so there are a few things
> that seem murky. I suppose that are other people in similar
> situations.
> I can think of a few things that don't seem entirely clear in the
> documentation and FAQ.
> I'm guessing that invoking regular Windows/.NET executables would
> mostly just work, with the following caveat:
> - stdin/stdout/stderr redirection and piping would still work, even
> when piping with cygwin-linked programs (care with charset and
> end-of-line conventions needs to be taken, however);
Right.
> - UNIX-style sockets are out of the question;
If you want your non-cygwin program communicate through Cygwin sockets, you
are in for a lot of trouble. Not strictly "out of question", but "largely not
worth the time spent".
> - the usual Window permission model would still be used;
More or less. There's caveats imposed by POSIX approximation of Windows ACLs.
> - if the regular Windows/.NET executable accepts a file or directory
> path as argument, it still needs to be written in the Windows style
> (i.e. "C:\\foobar\\" instead of "/cygdrive/c/foobar");
"C:/foobar" would work in most cases, so do "/foobar", assuming you know what
you are doing.
> - the locale of the cygwin bash process may cause problems when
> passing arguments to the regular Windows program.
If it's usual LANG=whatever.UTF-8, yes.
If it's more friendly single-byte encoding, should not be a problem.
> Am I mostly correct? So far it seems to work. Am I missing other caveat?
> Would it make sense to have all this summarized in the FAQ?
You forgot another important moment. Since non-cygwin applications have no
conception of pty's, running them in default Cygwin terminal (mintty) and read
their output may prove to be a challenge.
You could, however, use native console instead (i.e. running bash directly,
instead of letting mintty do it). Combined with appropriate LANG= settings,
that could be the way to go.
P.S.
----------8<----------8<----------8<----------
case "$TERM" in
xterm*)
LANG=ru_RU.UTF-8
;;
*)
LANG=ru_RU.CP866
;;
esac
export LANG
---------->8---------->8---------->8----------
--
WBR,
Andrey Repin (anrdaemon@yandex.ru) 05.11.2014, <21:57>
Sorry for my terrible english...
--
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