Last active
January 30, 2018 07:25
-
-
Save gocha/d12dadc8e8c14337bceba951d7e088e9 to your computer and use it in GitHub Desktop.
Simple runwin32 launcher for Cygwin+rsh
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# | |
# Note: | |
# - Environment variables must be set before running. This script doesn't import any user profiles. | |
# Add Windows system directory paths to the PATH, | |
# to allow to use cmd.exe and any other standard commands. | |
export PATH="$(cygpath -S):$(cygpath -W):$PATH" | |
# Add some common system variables. | |
# | |
# You may want this section, only if you're running the script via remote shell, | |
# since the rsh daemon doesn't import Windows environment variables at all. | |
#[ ! -v COMPUTERNAME ] && export COMPUTERNAME="$(hostname)" | |
#[ ! -v SYSTEMDRIVE ] && export SYSTEMDRIVE="$(cygpath -w -W | cut -f1 -d '\')" | |
#[ ! -v TEMP ] && export TEMP="$(cygpath -w -F 0x001c)\Temp" | |
#[ ! -v TMP ] && export TMP="$TEMP" | |
#[ ! -v USERNAME ] && export USERNAME="$(id -un)" | |
#[ ! -v USERPROFILE ] && export USERPROFILE="$(cygpath -w -F 0x0028)" | |
# Run specified command line. | |
# Piped by cat, otherwise remote shell will output corrupted text. | |
# | |
# Known Issue: | |
# When Cygwin launches a Win32 process, its arguments are escaped by MSVC escaping rule. | |
# Thus, commands which follow an another escaping rule may get unexpected value. | |
# | |
# For example, built-in shell commands (such as dir) doesn't follow MSVC escaping rule. | |
# `dir "C:\Program Files\"` will get replaced by dir `"C:\Program Files\\"` | |
# and such a conversion sometimes may cause an error. | |
cmd.exe /c "$@" | cat | |
exit $PIPESTATUS |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment