-
Notifications
You must be signed in to change notification settings - Fork 33
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
path-conversion: Prevent conversion of commandline flags. #11
Conversation
Why is this needed? Wouldn't it be simpler to stick to the documented path conversion rules [1]? I.e. write |
@kblees I use a lot of bash-scripts with long arguments myself in my daily work-flow, and having an option to disable path-conversions seems pretty convenient. But that's just my two cents. |
Very interesting idea! I'd love to have this feature, with minor changes:
|
Ok wait a minute. I think I know now what was my problem. I was trying to use the following switch |
@nalla while that is correct, it struck my as a major revelation that having the option to switch off the posix2windows mangling wholesale depending on an environment variable is just brilliant. Now that I think of it: even in our test suite, we could benefit from this: our Or do I miss anything? |
Or we could just add another flag to the If we add new environment variables, they should be prefixed with |
What I can do is change the variable name to
I must decline due to lack of knowledge and understanding. But If someone else would be willing to go for it - please do so 👍 |
When calling windows native apps from MSYS2, the runtime tries to convert commandline arguments by a specific set of rules. See [MinGW wiki] (http://www.mingw.org/wiki/Posix_path_conversion). If the user does not want that behavior on a big scale, e.g. inside a bash script, the user can now set the the environment variable `MSYS_NO_PATHCONV` when calling native windows commands. Signed-off-by: 마누엘 <nalla@hamal.uberspace.de>
The disadvantage of this is that |
Well, I just tested this. With the following #include <stdio.h>
int main(int argc, char **argv)
{
int i;
for (i = 0; i < argc; i++)
fprintf(stderr, "arg %d: '%s'\n", i, argv[i]);
return 0;
} and a patched $ echo-args /h
arg 0: 'C:\censored\echo-args.exe'
arg 1: 'H:/'
$ MSYS_NO_PATHCONV=1 echo-args /h
arg 0: 'C:\censored\echo-args.exe'
arg 1: '/h' Sweet!!! |
path-conversion: Prevent conversion of commandline flags.
Sorry that it takes so long to release this... I encountered build problems in 32-bit mode, but I think that I'll resolve them soon. |
Okay, finally resolved and uploaded to the Pacman repository. |
@dscho it seems like setting the |
@kumarharsh indeed it is. See 3a68b5b#diff-ee01d88e1ff6a07b0dc99ffc52c1e9f6R348 - The logic only checks if the variable has any value. |
OK, thanks. So setting it to I must really commend you guys for adding this in. It proved to be a lifesaver for me - I was writing a cross-platform Makefile which was running with the MSYS environment (but from Powershell) and I was trying to mount docker directories. It became such a mess that no matter what I tried, either MSYS was mucking up the path, or docker couldn't read it. This was the only reason I was maintaining a fork of the makefile in powershell PS1 scripts. Now, I'm just setting the environment variable when I need it: Before:An example of the makefile without this variable (and still didn't work because MSYS was re-translating the windows paths - also I'm relatively new to makefile so this might not be the best way to do it) uname_S := $(shell sh -c 'uname -s 2>/dev/null || echo not')
_mkfile_path := $(abspath $(lastword $(MAKEFILE_LIST)))
_pwd := $(patsubst %/,%,$(dir $(_mkfile_path)))
ifeq ($(uname_S),Linux) # Linux
WORKING_DIR = $(_pwd)
endif
ifneq (,$(findstring MSYS_NT,$(uname_S))) # Windows
_drive := $(shell echo $(firstword $(subst :, ,$(_pwd))) | tr A-Z a-z)
_path := $(subst \\,/,$(lastword $(subst :, ,$(_pwd))))
WORKING_DIR := /$(_drive)$(subst :,,$(_path))
endif
.PHONY: restoredb
restoredb: ## Restore all data from a sql file to the database
docker run -u postgres -v $(WORKING_DIR)/dumps/$(DBName)_dump.sql:/tmp/dump.sql --net host --rm postgres:9.5 psql -f /tmp/dump.sql -h localhost -U postgres $(DBName) And the actual function in Powershell which did work: function __getPath($path) {
return [regex]::replace( # First, convert the drive letter from windows style to unix style, i.e, C:\ to /c/
$path,
'([\w]):\\', {
param($m)
'/'+$m.Groups[1].Value.toLower()+'/'
}
).replace('\', '/') # Then, replace the remaining '\' to '/'
}
function make-restore {
Param(
[parameter(Mandatory=$true,position=0)]
[String]
$app
)
$DB_NAME = "pl_$($app)"
$hostPath = __getPath "$($pwd)/dumps/$($DB_NAME)_dump.sql"
docker run -u postgres --net host -v "$($hostPath):/tmp/dump.sql" --rm postgres:9.5 psql -h localhost -U postgres -f /tmp/dump.sql $DB_NAME
echo "Restored database pl_core"
} After I found this variableMy makefile: .PHONY: restoredb
restoredb: export MSYS_NO_PATHCONV=1 # stop path conversion for msys in windows
restoredb: ## Restore all data from a sql file to the database
docker run -u postgres -v `pwd`/dumps/$(DBName)_dump.sql:/tmp/dump.sql --net host --rm postgres:9.5 psql -f /tmp/dump.sql -h localhost -U postgres $(DBName) |
When calling windows native apps from MSYS2, the runtime tries to convert commandline arguments by a specific set of rules. See [MinGW wiki] (https://web.archive.org/web/20201112005258/http://www.mingw.org/wiki/Posix_path_conversion). If the user does not want that behavior on a big scale, e.g. inside a bash script, the user can now set the the environment variable `MSYS_NO_PATHCONV` when calling native windows commands. This is a feature that has been introduced in Git for Windows via git-for-windows/msys2-runtime#11 and it predates support for the `MSYS2_ENV_CONV_EXCL` and `MSYS2_ARG_CONV_EXCL` environment variables; Many users find the simplicity of `MSYS_NO_PATHCONV` appealing. So maybe MSYS2 wants that feature, too? Signed-off-by: 마누엘 <nalla@hamal.uberspace.de>
When calling windows native apps from MSYS2, the runtime tries to convert commandline arguments by a specific set of rules. This idea was inherited from the MSys/MinGW project (which is now seemingly stale, yet must be credited with championing this useful feature, see MinGW wiki https://web.archive.org/web/20201112005258/http://www.mingw.org/wiki/Posix_path_conversion). If the user does not want that behavior on a big scale, e.g. inside a Bash script, with the changes introduced in this commit, the user can now set the the environment variable `MSYS_NO_PATHCONV` when calling native windows commands. This is a feature that has been introduced in Git for Windows via git-for-windows/msys2-runtime#11 and it predates support for the `MSYS2_ENV_CONV_EXCL` and `MSYS2_ARG_CONV_EXCL` environment variables in the MSYS2 runtime; Many users find the simplicity of `MSYS_NO_PATHCONV` appealing. So let's teach MSYS2 proper this simple trick that still allows using the sophisticated `MSYS2_*_CONV_EXCL` facilities but also allows a convenient catch-all "just don't convert anything" knob. Signed-off-by: 마누엘 <nalla@hamal.uberspace.de>
When calling windows native apps from MSYS2, the runtime tries to convert commandline arguments by a specific set of rules. This idea was inherited from the MSys/MinGW project (which is now seemingly stale, yet must be credited with championing this useful feature, see MinGW wiki https://web.archive.org/web/20201112005258/http://www.mingw.org/wiki/Posix_path_conversion). If the user does not want that behavior on a big scale, e.g. inside a Bash script, with the changes introduced in this commit, the user can now set the the environment variable `MSYS_NO_PATHCONV` when calling native windows commands. This is a feature that has been introduced in Git for Windows via git-for-windows/msys2-runtime#11 and it predates support for the `MSYS2_ENV_CONV_EXCL` and `MSYS2_ARG_CONV_EXCL` environment variables in the MSYS2 runtime; Many users find the simplicity of `MSYS_NO_PATHCONV` appealing. So let's teach MSYS2 proper this simple trick that still allows using the sophisticated `MSYS2_*_CONV_EXCL` facilities but also offers a convenient catch-all "just don't convert anything" knob. Signed-off-by: 마누엘 <nalla@hamal.uberspace.de> Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
When calling windows native apps from MSYS2, the runtime tries to convert commandline arguments by a specific set of rules. This idea was inherited from the MSys/MinGW project (which is now seemingly stale, yet must be credited with championing this useful feature, see MinGW wiki https://web.archive.org/web/20201112005258/http://www.mingw.org/wiki/Posix_path_conversion). If the user does not want that behavior on a big scale, e.g. inside a Bash script, with the changes introduced in this commit, the user can now set the the environment variable `MSYS_NO_PATHCONV` when calling native windows commands. This is a feature that has been introduced in Git for Windows via git-for-windows/msys2-runtime#11 and it predates support for the `MSYS2_ENV_CONV_EXCL` and `MSYS2_ARG_CONV_EXCL` environment variables in the MSYS2 runtime; Many users find the simplicity of `MSYS_NO_PATHCONV` appealing. So let's teach MSYS2 proper this simple trick that still allows using the sophisticated `MSYS2_*_CONV_EXCL` facilities but also offers a convenient catch-all "just don't convert anything" knob. Signed-off-by: 마누엘 <nalla@hamal.uberspace.de> Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
When calling windows native apps from MSYS2, the runtime tries to convert commandline arguments by a specific set of rules. This idea was inherited from the MSys/MinGW project (which is now seemingly stale, yet must be credited with championing this useful feature, see MinGW wiki https://web.archive.org/web/20201112005258/http://www.mingw.org/wiki/Posix_path_conversion). If the user does not want that behavior on a big scale, e.g. inside a Bash script, with the changes introduced in this commit, the user can now set the the environment variable `MSYS_NO_PATHCONV` when calling native windows commands. This is a feature that has been introduced in Git for Windows via git-for-windows/msys2-runtime#11 and it predates support for the `MSYS2_ENV_CONV_EXCL` and `MSYS2_ARG_CONV_EXCL` environment variables in the MSYS2 runtime; Many users find the simplicity of `MSYS_NO_PATHCONV` appealing. So let's teach MSYS2 proper this simple trick that still allows using the sophisticated `MSYS2_*_CONV_EXCL` facilities but also offers a convenient catch-all "just don't convert anything" knob. Signed-off-by: 마누엘 <nalla@hamal.uberspace.de> Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
When calling windows native apps from MSYS2, the runtime tries to convert commandline arguments by a specific set of rules. This idea was inherited from the MSys/MinGW project (which is now seemingly stale, yet must be credited with championing this useful feature, see MinGW wiki https://web.archive.org/web/20201112005258/http://www.mingw.org/wiki/Posix_path_conversion). If the user does not want that behavior on a big scale, e.g. inside a Bash script, with the changes introduced in this commit, the user can now set the the environment variable `MSYS_NO_PATHCONV` when calling native windows commands. This is a feature that has been introduced in Git for Windows via git-for-windows/msys2-runtime#11 and it predates support for the `MSYS2_ENV_CONV_EXCL` and `MSYS2_ARG_CONV_EXCL` environment variables in the MSYS2 runtime; Many users find the simplicity of `MSYS_NO_PATHCONV` appealing. So let's teach MSYS2 proper this simple trick that still allows using the sophisticated `MSYS2_*_CONV_EXCL` facilities but also offers a convenient catch-all "just don't convert anything" knob. Signed-off-by: 마누엘 <nalla@hamal.uberspace.de> Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
When calling windows native apps from MSYS2, the runtime tries to convert commandline arguments by a specific set of rules. This idea was inherited from the MSys/MinGW project (which is now seemingly stale, yet must be credited with championing this useful feature, see MinGW wiki https://web.archive.org/web/20201112005258/http://www.mingw.org/wiki/Posix_path_conversion). If the user does not want that behavior on a big scale, e.g. inside a Bash script, with the changes introduced in this commit, the user can now set the the environment variable `MSYS_NO_PATHCONV` when calling native windows commands. This is a feature that has been introduced in Git for Windows via git-for-windows/msys2-runtime#11 and it predates support for the `MSYS2_ENV_CONV_EXCL` and `MSYS2_ARG_CONV_EXCL` environment variables in the MSYS2 runtime; Many users find the simplicity of `MSYS_NO_PATHCONV` appealing. So let's teach MSYS2 proper this simple trick that still allows using the sophisticated `MSYS2_*_CONV_EXCL` facilities but also offers a convenient catch-all "just don't convert anything" knob. Signed-off-by: 마누엘 <nalla@hamal.uberspace.de> Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
When calling windows native apps from MSYS2, the runtime tries to convert commandline arguments by a specific set of rules. This idea was inherited from the MSys/MinGW project (which is now seemingly stale, yet must be credited with championing this useful feature, see MinGW wiki https://web.archive.org/web/20201112005258/http://www.mingw.org/wiki/Posix_path_conversion). If the user does not want that behavior on a big scale, e.g. inside a Bash script, with the changes introduced in this commit, the user can now set the the environment variable `MSYS_NO_PATHCONV` when calling native windows commands. This is a feature that has been introduced in Git for Windows via git-for-windows#11 and it predates support for the `MSYS2_ENV_CONV_EXCL` and `MSYS2_ARG_CONV_EXCL` environment variables in the MSYS2 runtime; Many users find the simplicity of `MSYS_NO_PATHCONV` appealing. So let's teach MSYS2 proper this simple trick that still allows using the sophisticated `MSYS2_*_CONV_EXCL` facilities but also offers a convenient catch-all "just don't convert anything" knob. Signed-off-by: 마누엘 <nalla@hamal.uberspace.de> Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
When calling windows native apps from MSYS2, the runtime tries to convert commandline arguments by a specific set of rules. This idea was inherited from the MSys/MinGW project (which is now seemingly stale, yet must be credited with championing this useful feature, see MinGW wiki https://web.archive.org/web/20201112005258/http://www.mingw.org/wiki/Posix_path_conversion). If the user does not want that behavior on a big scale, e.g. inside a Bash script, with the changes introduced in this commit, the user can now set the the environment variable `MSYS_NO_PATHCONV` when calling native windows commands. This is a feature that has been introduced in Git for Windows via git-for-windows/msys2-runtime#11 and it predates support for the `MSYS2_ENV_CONV_EXCL` and `MSYS2_ARG_CONV_EXCL` environment variables in the MSYS2 runtime; Many users find the simplicity of `MSYS_NO_PATHCONV` appealing. So let's teach MSYS2 proper this simple trick that still allows using the sophisticated `MSYS2_*_CONV_EXCL` facilities but also offers a convenient catch-all "just don't convert anything" knob. Signed-off-by: 마누엘 <nalla@hamal.uberspace.de> Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
When calling windows native apps from MSYS2, the runtime tries to convert commandline arguments by a specific set of rules. This idea was inherited from the MSys/MinGW project (which is now seemingly stale, yet must be credited with championing this useful feature, see MinGW wiki https://web.archive.org/web/20201112005258/http://www.mingw.org/wiki/Posix_path_conversion). If the user does not want that behavior on a big scale, e.g. inside a Bash script, with the changes introduced in this commit, the user can now set the the environment variable `MSYS_NO_PATHCONV` when calling native windows commands. This is a feature that has been introduced in Git for Windows via git-for-windows/msys2-runtime#11 and it predates support for the `MSYS2_ENV_CONV_EXCL` and `MSYS2_ARG_CONV_EXCL` environment variables in the MSYS2 runtime; Many users find the simplicity of `MSYS_NO_PATHCONV` appealing. So let's teach MSYS2 proper this simple trick that still allows using the sophisticated `MSYS2_*_CONV_EXCL` facilities but also offers a convenient catch-all "just don't convert anything" knob. Signed-off-by: 마누엘 <nalla@hamal.uberspace.de> Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
When calling windows native apps from MSYS2, the runtime tries to convert commandline arguments by a specific set of rules. This idea was inherited from the MSys/MinGW project (which is now seemingly stale, yet must be credited with championing this useful feature, see MinGW wiki https://web.archive.org/web/20201112005258/http://www.mingw.org/wiki/Posix_path_conversion). If the user does not want that behavior on a big scale, e.g. inside a Bash script, with the changes introduced in this commit, the user can now set the the environment variable `MSYS_NO_PATHCONV` when calling native windows commands. This is a feature that has been introduced in Git for Windows via git-for-windows/msys2-runtime#11 and it predates support for the `MSYS2_ENV_CONV_EXCL` and `MSYS2_ARG_CONV_EXCL` environment variables in the MSYS2 runtime; Many users find the simplicity of `MSYS_NO_PATHCONV` appealing. So let's teach MSYS2 proper this simple trick that still allows using the sophisticated `MSYS2_*_CONV_EXCL` facilities but also offers a convenient catch-all "just don't convert anything" knob. Signed-off-by: 마누엘 <nalla@hamal.uberspace.de> Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
When calling windows native apps from MSYS2, the runtime tries to convert commandline arguments by a specific set of rules. This idea was inherited from the MSys/MinGW project (which is now seemingly stale, yet must be credited with championing this useful feature, see MinGW wiki https://web.archive.org/web/20201112005258/http://www.mingw.org/wiki/Posix_path_conversion). If the user does not want that behavior on a big scale, e.g. inside a Bash script, with the changes introduced in this commit, the user can now set the the environment variable `MSYS_NO_PATHCONV` when calling native windows commands. This is a feature that has been introduced in Git for Windows via git-for-windows/msys2-runtime#11 and it predates support for the `MSYS2_ENV_CONV_EXCL` and `MSYS2_ARG_CONV_EXCL` environment variables in the MSYS2 runtime; Many users find the simplicity of `MSYS_NO_PATHCONV` appealing. So let's teach MSYS2 proper this simple trick that still allows using the sophisticated `MSYS2_*_CONV_EXCL` facilities but also offers a convenient catch-all "just don't convert anything" knob. Signed-off-by: 마누엘 <nalla@hamal.uberspace.de> Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
When calling windows apps from MSYS2, the runtime tries to convert
windows style commandline flags like ´/h´ into
C:/path/to/msys2/h
.If the user does not want that behavior the user can now set the the
environment variable WINSTYLE_FLAGS_ONLY when calling that command.