OSDN Git Service

Package and release command gets target from vars file.
[osdn-codes/osdn-cli.git] / lib / osdn / cli / command / login.rb
index ddb3352..8721683 100644 (file)
@@ -30,17 +30,19 @@ module OSDN; module CLI; module Command
     end
 
     def launch_brwoser(url)
-      puts "Access follwoing URL to get auth code;\n#{url}"
-      %w(/usr/bin/xdg-open /usr/bin/X11/xdg-open /usr/local/bin/xdg-open
-             /usr/bin/x-www-browser /usr/bin/firefox /usr/local/bin/firefox
-            ).each do |bin|
-        File.executable?(bin) or next
-        exec(bin, url) if fork.nil?
-        return
+      puts "Access following URL to get auth code;\n#{url}"
+      if ENV['DISPLAY']
+        %w(/usr/bin/xdg-open /usr/bin/X11/xdg-open /usr/local/bin/xdg-open
+               /usr/bin/x-www-browser /usr/bin/firefox /usr/local/bin/firefox
+              ).each do |bin|
+          File.executable?(bin) or next
+          exec(bin, url) if fork.nil?
+          return
+        end
       end
       case RUBY_PLATFORM
       when /mswin|msys|mingw|cygwin|bccwin|wince|emc/
-        exec("start #{url}") if fork.nil?
+        spawn("start #{url.gsub(/&/, '^&')}")
       when /darwin|mac os/
         exec("/usr/bin/open", url) if fork.nil?
       end