Enter code here...

As one of the multitudes stuck behind a corporate firewall, I'm attempting 
to find a work-around for using the WinRPM package (see this 
issue: https://github.com/JuliaPackaging/WinRPM.jl/issues/40).

In the process, I have uncovered some unusual behavior in the run command - 
it appears to be inserting spurious "\r" tokens into the return string.

Specifically, I am attempting to implement tkelman's suggestion of 
replacing the download function in WinRPM.jl with a call to the command 
readstring(`powershell -Command "(new-object 
net.webclient).DownloadString(\"$source\")"`)


When I run this command directly in powershell, it works fine.  The call:
PS D:> (new-object net.webclient).DownloadString(
"https://cache.julialang.org/http://download.opensuse.org/repositories/windows:/mingw:/win32/openSUSE_13.2/repodata/repomd.xml";
)
outputs:
<?xml version="1.0" encoding="UTF-8"?>
<repomd xmlns="http://linux.duke.edu/metadata/repo"; xmlns:rpm=
"http://linux.duke.edu/metadata/rpm";>
 <revision>1476324538</revision>
 <tags>
   <repo>
obsrepository://build.opensuse.org/windows:mingw:win32/openSUSE_13.2</repo>
 </tags>
<data type="filelists">
  <checksum type="sha256">
362593bb130a5619226350c66aa68aeca30abe84e95756d8e12ca3e511daa0f1</checksum>
  <open-checksum type="sha256">
cc48185bdbc5003f12311d447ea013209bc6da642960e4477dba36fdf34bebca
</open-checksum>
  <location href=
"repodata/362593bb130a5619226350c66aa68aeca30abe84e95756d8e12ca3e511daa0f1-filelists.xml.gz"
/>
  <timestamp>1476324543</timestamp>
  <size>1296372</size>
  <open-size>20002367</open-size>
</data>
<data type="other">
  <checksum type="sha256">
4f7e3bc3ef333c833a261b3c6587026fae78affc9acff97eaf1e7bc52b791b83</checksum>
  <open-checksum type="sha256">
17a5e12a0aa74c9f63f702cef354bc6ebe3b26b5eb7c5f9e7911e90f1e918bb1
</open-checksum>
  <location href=
"repodata/4f7e3bc3ef333c833a261b3c6587026fae78affc9acff97eaf1e7bc52b791b83-other.xml.gz"
/>
  <timestamp>1476324543</timestamp>
  <size>149321</size>
  <open-size>916739</open-size>
</data>
<data type="primary">
  <checksum type="sha256">
1fd9c3d32946a500a759cd90dbaf1b5e93f979d88b7631d7d8a08a8a6ef6aa6b</checksum>
  <open-checksum type="sha256">
411874cbb061a17b86f0984ca58b4eed8724e1955ff0245787075b8d6091a17a
</open-checksum>
  <location href=
"repodata/1fd9c3d32946a500a759cd90dbaf1b5e93f979d88b7631d7d8a08a8a6ef6aa6b-primary.xml.gz"
/>
  <timestamp>1476324543</timestamp>
  <size>397298</size>
  <open-size>3647955</open-size>
</data>
</repomd>

However, that same call in julia:
source = "
https://cache.julialang.org/http://download.opensuse.org/repositories/windows:/mingw:/win32/openSUSE_13.2/repodata/repomd.xml";
readstring(`powershell -Command "(new-object 
net.webclient).DownloadString(\"$source\")"`)
outputs:
<?xml version="1.0" encoding="UTF-8"?>
<repomd xmlns="http://linux.duke.edu/metadata/repo"; xmlns:rpm=
"http://linux.duk
e.edu/metadata/rpm">
 <revision>1476324538</revision>
 <tags>
   <repo>
obsrepository://build.opensuse.org/windows:mingw:win32/openSUSE_13.2</
repo>
 </tags>
<data type="filelists">
  <checksum type="sha256">
362593bb130a5619226350c66aa68aeca30abe84e95756d8e12ca
3e511daa0f1</checksum>
  <open-checksum type="sha256">
cc48185bdbc5003f12311d447ea013209bc6da642960e447
7dba36fdf34bebca</open-checksum>
  <location href=
"repodata/362593bb130a5619226350c66aa68aeca30abe84e95756d8e12c
a3e511daa0f1-filelists.xml.gz"/>
  <timestamp>1476324543</timestamp>
  <size>1296372</size>
  <open-size>20002367</open-size>
</data>
<data type="other">
  <checksum type="sha256">
4f7e3bc3ef333c833a261b3c6587026fae78affc9acff97eaf1e7
bc52b791b83</checksum>
  <open-checksum type="sha256">
17a5e12a0aa74c9f63f702cef354bc6ebe3b26b5eb7c5f9e
7911e90f1e918bb1</open-checksum>
  <location href=
"repodata/4f7e3bc3ef333c833a261b3c6587026fae78affc9acff97eaf1e
7bc52b791b83-other.xml.gz"/>
  <timestamp>1476324543</timestamp>
  <size>149321</size>
  <open-size>916739</open-size>
</data>
<data type="primary">
  <checksum type="sha256">
1fd9c3d32946a500a759cd90dbaf1b5e93f979d88b7631d7d8a08
a8a6ef6aa6b</checksum>
  <open-checksum type="sha256">
411874cbb061a17b86f0984ca58b4eed8724e1955ff02457
87075b8d6091a17a</open-checksum>
  <location href=
"repodata/1fd9c3d32946a500a759cd90dbaf1b5e93f979d88b7631d7d8a0
8a8a6ef6aa6b-primary.xml.gz"/>
  <timestamp>1476324543</timestamp>
  <size>397298</size>
  <open-size>3647955</open-size>
</data>
</repomd>

Notice that the output has now been spuriously formatted to be fixed with. 
 Looking at the raw output of the run command, it has inserted extra "\r" 
tokens into the return string to force the fixed with behavior.

Is this intentional?  Is there a workaround to prevent this?

Regards,
Jason Bates

Reply via email to