RE: Re: need help with bash -c command with cygpath
Jay wrote on Friday, January 11, 2008 3:14 PM:: That's still somewhat wasteful, starting bash just to get a vim alias - why not use the full name gvim, and bypass the bash process to begin with? you right, i'm going to remove it, thanks. My main problem now is that for some reason the leading backslash on UNC names is getting dropped when calling bash -c from the windows command prompt, even when using just single quotes. So if you run this from a windows command prompt: H:\C:\cygwin\bin\bash -v -c '\\UNC_PATH\Dir' \UNC_PATH\Dir --Leading backslash dropped /usr/bin/bash: UNC_PATHDir: command not found It drops off the leading backslash. When you run it from Cygwin bash: bash -v -c '\\UNC_PATH\Dir' \\UNC_PATH\Dir --The leading backslash is preserved. bash: \UNC_PATHDir: command not found I know i can make it work by piping the path into sed, but I'm just wondering why i'm losing the leading backslash when running from windows. Maybe dos is passing in the single quotes as double quotes. dos (i.e. cmd.exe) does not have the same quoting rules as bash, so \\ inside single quotes means the same as it does inside double quotes in bash. Why are you even trying to use backslashes? There's no need (even in cmd.exe), but there's certainly no point in using them in a posix command. Just replace all backslashes with forward slashes and you've sidestepped the problem. If you absolutely MUST have backslashes, from cmd.exe, you need to double each backslash: H:\C:\cygwin\bin\bash -v -c 'UNC_PATH\\Dir' (actually only the first really needs to be doubled, because \ has no special meaning if it's followed by a letter) Phil -- Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple Problem reports: http://cygwin.com/problems.html Documentation: http://cygwin.com/docs.html FAQ: http://cygwin.com/faq/
Re: Re: need help with bash -c command with cygpath
H:\C:\cygwin\bin\bash -v -c 'UNC_PATH\\Dir' (actually only the first really needs to be doubled, because \ has no special meaning if it's followed by a letter) Phil I'm getting the path from the registry via a right click menu and passing it into the bash -c command. But the leading slash is getting removed on UNC paths. I think i'm going to have to sed it. -- Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple Problem reports: http://cygwin.com/problems.html Documentation: http://cygwin.com/docs.html FAQ: http://cygwin.com/faq/
RE: Re: need help with bash -c command with cygpath
On 11 January 2008 15:51, Phil Betts wrote: If you absolutely MUST have backslashes, from cmd.exe, you need to double each backslash: H:\C:\cygwin\bin\bash -v -c 'UNC_PATH\\Dir' That doesn't work for me. Adding the '-x' option to bash is very handy for debugging these sorts of problems, it shows you what bash thinks it's actually seeing:- C:\Documents and Settings\dkC:\cygwin\bin\bash -v -x -c 'UNC_PATH\\Dir' \\UNC_PATH\Dir + '\UNC_PATHDir' /usr/bin/bash: \UNC_PATHDir: command not found I believe what is needed is 1) outer double-quotes, for cmd's benefit, 2) inner single-quotes, for bash's benefit, 3) double up the slashes /as well/, because there's one more level of quoting being stripped than I can account for, but anyway it works for me: C:\Documents and Settings\dkC:\cygwin\bin\bash -v -x -c 'UNC_PATH\\Dir' '\\UNC_PATH\Dir' + '\\UNC_PATH\Dir' /usr/bin/bash: \\UNC_PATH\Dir: command not found C:\Documents and Settings\dk If I wasn't trying to execute a directory but list it instead, I'd say C:\cygwin\bin\bash -v -x -c ls -la 'UNC_PATH\\Dir' (just using this example to illustrate how the outer quotes protect the bash commandline from cmd, and the inner quotes are part of the bash commandline). cheers, DaveK -- Can't think of a witty .sigline today -- Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple Problem reports: http://cygwin.com/problems.html Documentation: http://cygwin.com/docs.html FAQ: http://cygwin.com/faq/