Mina: Help wanted: Windows mingw32 shell (git bash) - CRLF

Created on 10 Jan 2013  路  12Comments  路  Source: mina-deploy/mina

First things first - thanks for great tool :+1:

I am using Windows now (yeah...) and trying to deploy with Mina.

I found that generated bash script on Windows Git Bash (mingw32 standard shell) has CRLF line endings, but linux use LF, so there are errors like "Unexpected EOF".

I write this generated script to file, convert line endings to LF and use it manually - everything works fine.

Is this a Mina feature or a mingw32 bug or misconfiguration? :)

enhancement

Most helpful comment

Now I know why.
Shellwords.escape method for Ruby doesn't support windows environment.
So, in order to fix it, I added a little bit of code to the lib/mina.rb.
It works!

I'm a newbie, so.... but anyway锛宨t works.

# lib/mina.rb
module Mina
  #if windows os
  require 'rbconfig'
  is_windows = (RbConfig::CONFIG['host_os'] =~ /mswin|mingw|cygwin/) 
  if is_windows
    module Shellwords
      def shellescape(str)
          '"' + str.gsub(/\\(?=\\*\")/, "\\\\\\").gsub(/\"/, "\\\"").gsub(/\\$/, "\\\\\\").gsub("%", "%%") + '"'
      end

      module_function :shellescape
      class << self
        alias escape shellescape
      end
    end
  end
...

All 12 comments

Hm. Are you trying to deploy to a Windows server, or a running on a Windows workstation?

Thanks for the heads up鈥攗nfortunately we don't have a Windows machine right now to test but I suppose we can work on some hypothetical fixes.

I'm having the same issue. On Win7x64 trying to deploy to CentOS

 bash: -c line 106: unexpected EOF while looking for a matching `"'

One of my co-workers have this problem as well when deploying to a Ubuntu server. He's on Vista (no comments) with Git Bash (mingw32) and we are using Mina 0.3.0.

I got the same error as @rezen on Windows 8.1 x64 trying to deploy to Ubuntu LTS 12.04.3 x64.

@reterius i have same error in windows.
How rite this generated script to file, convert line endings to LF and use it manually ?

Now I know why.
Shellwords.escape method for Ruby doesn't support windows environment.
So, in order to fix it, I added a little bit of code to the lib/mina.rb.
It works!

I'm a newbie, so.... but anyway锛宨t works.

# lib/mina.rb
module Mina
  #if windows os
  require 'rbconfig'
  is_windows = (RbConfig::CONFIG['host_os'] =~ /mswin|mingw|cygwin/) 
  if is_windows
    module Shellwords
      def shellescape(str)
          '"' + str.gsub(/\\(?=\\*\")/, "\\\\\\").gsub(/\"/, "\\\"").gsub(/\\$/, "\\\\\\").gsub("%", "%%") + '"'
      end

      module_function :shellescape
      class << self
        alias escape shellescape
      end
    end
  end
...

works great !! not newbie .... expert

Did this tweak make it into the codebase?

Would it help progress this issue, if I put @insub's fix into a pull request?

@coredevelopers: any reason why this isnt picked up? Solution by insub works. Why not do minor patches to support the windows community?

It works indeed. Thanks!

Can someome test github master if this works?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

folivi picture folivi  路  4Comments

Ilya-Kuchaev picture Ilya-Kuchaev  路  4Comments

misteral picture misteral  路  10Comments

thaichor picture thaichor  路  8Comments

davidhq picture davidhq  路  10Comments