Author: acmurthy
Date: Mon Sep 10 14:29:44 2012
New Revision: 1382877

URL: http://svn.apache.org/viewvc?rev=1382877&view=rev
Log:
HADOOP-8739. Fix command line parsing on Windows. Contributed by Bikas Saha.

Modified:
    hadoop/common/branches/branch-1-win/CHANGES.branch-1-win.txt
    hadoop/common/branches/branch-1-win/bin/hadoop.cmd
    hadoop/common/branches/branch-1-win/bin/hdfs.cmd
    hadoop/common/branches/branch-1-win/bin/mapred.cmd

Modified: hadoop/common/branches/branch-1-win/CHANGES.branch-1-win.txt
URL: 
http://svn.apache.org/viewvc/hadoop/common/branches/branch-1-win/CHANGES.branch-1-win.txt?rev=1382877&r1=1382876&r2=1382877&view=diff
==============================================================================
--- hadoop/common/branches/branch-1-win/CHANGES.branch-1-win.txt (original)
+++ hadoop/common/branches/branch-1-win/CHANGES.branch-1-win.txt Mon Sep 10 
14:29:44 2012
@@ -94,6 +94,9 @@ BUG FIXES
 
     HDFS-3763. TestNameNodeMXBean fails on Windows. (Brandon Li via suresh)
 
+    HADOOP-8739. Fix command line parsing on Windows. (Bikas Saha via
+    acmurthy)
+
     HDFS-3766. Fix TestStorageRestore on Windows. (Brandon Li via suresh)
 
     HADOOP-8657. Fix TestCLI to not hardcode file length since it's

Modified: hadoop/common/branches/branch-1-win/bin/hadoop.cmd
URL: 
http://svn.apache.org/viewvc/hadoop/common/branches/branch-1-win/bin/hadoop.cmd?rev=1382877&r1=1382876&r2=1382877&view=diff
==============================================================================
--- hadoop/common/branches/branch-1-win/bin/hadoop.cmd (original)
+++ hadoop/common/branches/branch-1-win/bin/hadoop.cmd Mon Sep 10 14:29:44 2012
@@ -158,23 +158,26 @@ call :updatepath %HADOOP_BIN_PATH%
   set path_to_add=
   goto :eof
 
+@rem This changes %1, %2 etc. Hence those cannot be used after calling this.
 :make_command_arguments
   if "%2" == "" goto :eof
-  set _count=0
-  set _shift=1
-  for %%i in (%*) do (
-    set /a _count=!_count!+1
-    if !_count! GTR %_shift% ( 
-       if not defined _arguments (
-         set _arguments=%%i
-       ) else (
-          set _arguments=!_arguments! %%i
-       )
-    )
+  shift
+  set _arguments=
+  :MakeCmdArgsLoop 
+  if [%1]==[] goto :EndLoop 
+
+  if not defined _arguments (
+    set _arguments=%1
+  ) else (
+    set _arguments=!_arguments! %1
   )
+  shift
+  goto :MakeCmdArgsLoop 
+  :EndLoop 
   set hadoop-command-arguments=%_arguments%
   goto :eof
 
+
 :print_usage
   @echo Usage: hadoop COMMAND
   @echo where COMMAND is one of:

Modified: hadoop/common/branches/branch-1-win/bin/hdfs.cmd
URL: 
http://svn.apache.org/viewvc/hadoop/common/branches/branch-1-win/bin/hdfs.cmd?rev=1382877&r1=1382876&r2=1382877&view=diff
==============================================================================
--- hadoop/common/branches/branch-1-win/bin/hdfs.cmd (original)
+++ hadoop/common/branches/branch-1-win/bin/hdfs.cmd Mon Sep 10 14:29:44 2012
@@ -123,21 +123,31 @@ goto :eof
   @echo ^</service^>
   goto :eof
 
+@rem This changes %1, %2 etc. Hence those cannot be used after calling this.
 :make_command_arguments
   if "%2" == "" goto :eof
   set _count=0
+  set _hdfsarguments=
   if defined service_entry (set _shift=2) else (set _shift=1)
   if defined config_override (set /a _shift=!_shift! + 2)
-  for %%i in (%*) do (
-    set /a _count=!_count!+1
-    if !_count! GTR %_shift% ( 
-       if not defined _hdfsarguments (
-         set _hdfsarguments=%%i
-       ) else (
-          set _hdfsarguments=!_hdfsarguments! %%i
-       )
-    )
+  :SHIFTLOOP
+  set /a _count=!_count!+1
+  if !_count! GTR %_shift% goto :MakeCmdArgsLoop
+  shift
+  goto :SHIFTLOOP
+
+  :MakeCmdArgsLoop
+  if [%1]==[] goto :EndLoop 
+
+  if not defined _hdfsarguments (
+    set _hdfsarguments=%1
+  ) else (
+    set _hdfsarguments=!_hdfsarguments! %1
   )
+  shift
+  goto :MakeCmdArgsLoop 
+  :EndLoop 
+
   set hdfs-command-arguments=%_hdfsarguments%
   goto :eof
 

Modified: hadoop/common/branches/branch-1-win/bin/mapred.cmd
URL: 
http://svn.apache.org/viewvc/hadoop/common/branches/branch-1-win/bin/mapred.cmd?rev=1382877&r1=1382876&r2=1382877&view=diff
==============================================================================
--- hadoop/common/branches/branch-1-win/bin/mapred.cmd (original)
+++ hadoop/common/branches/branch-1-win/bin/mapred.cmd Mon Sep 10 14:29:44 2012
@@ -112,21 +112,31 @@ goto :eof
   @echo ^</service^>
   goto :eof
 
+@rem This changes %1, %2 etc. Hence those cannot be used after calling this.
 :make_command_arguments
   if "%2" == "" goto :eof
   set _count=0
+  set _mapredarguments=
   if defined service_entry (set _shift=2) else (set _shift=1)
   if defined config_override (set /a _shift=!_shift! + 2)
-  for %%i in (%*) do (
-    set /a _count=!_count!+1
-    if !_count! GTR %_shift% ( 
-       if not defined _mapredarguments (
-         set _mapredarguments=%%i
-       ) else (
-          set _mapredarguments=!_mapredarguments! %%i
-       )
-    )
+  :SHIFTLOOP
+  set /a _count=!_count!+1
+  if !_count! GTR %_shift% goto :MakeCmdArgsLoop
+  shift
+  goto :SHIFTLOOP
+
+  :MakeCmdArgsLoop
+  if [%1]==[] goto :EndLoop 
+
+  if not defined _mapredarguments (
+    set _mapredarguments=%1
+  ) else (
+    set _mapredarguments=!_mapredarguments! %1
   )
+  shift
+  goto :MakeCmdArgsLoop 
+  :EndLoop
+
   set mapred-command-arguments=%_mapredarguments%
   goto :eof
 


Reply via email to