Home > Mobile >  How to not escape pipe redirection symbols in Cygwin
How to not escape pipe redirection symbols in Cygwin

Time:11-28

I’ve got build scripts working perfectly for Linux bash. Currently I’d like to adapt build for Cygwin, to make it cross-platform. The problem is the build script uses pipe redirection like | and >, which need to be escaped with ^ when using with Cygwin’s ‘bash -c’.

I’m wondering is there any solution to not escape every pipe redirection symbol for Cygwin, maybe bash command line option or env var.

The example:

ls -l | tee 1.log, working perfectly in Linux, needs to be escaped in the following way to be used with Cygwin’s bash -c:

ls -l ^| tee 1.log

CodePudding user response:

I would assume bash -c "ls -l | tee 1.log" should do the trick for symbols like | and >. But if you want to use " inside the bash command, you might run into problems again (depends on the actual use of quotes, and how Cycgwin implemented/compiled bash).

In general, it would be safer to either run bash interactively and input the command there; or (if not possible) use a script file instead, e.g. bash script.sh.

  • Related