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]

Re: Running non-cygwin executables in cygwin bash terminal or script


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


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