<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Batch Scripting on MXI</title><link>https://mxii.eu.org/tags/batch-scripting/</link><description>Recent content in Batch Scripting on MXI</description><generator>Hugo -- gohugo.io</generator><language>en-us</language><lastBuildDate>Wed, 01 Apr 2020 21:45:11 +0300</lastBuildDate><atom:link href="https://mxii.eu.org/tags/batch-scripting/index.xml" rel="self" type="application/rss+xml"/><item><title>A case of adapting a CLI test command from *NIX to Windows</title><link>https://mxii.eu.org/2020/04/01/a-case-of-adapting-a-cli-test-command-from-nix-to-windows/</link><pubDate>Wed, 01 Apr 2020 21:45:11 +0300</pubDate><guid>https://mxii.eu.org/2020/04/01/a-case-of-adapting-a-cli-test-command-from-nix-to-windows/</guid><description>&lt;p>There is a package I wanted to publish to npmjs.com. That package provides a CLI tool among other features, and contains tests for that tool. Unfortunately, tests were made with only *NIX in mind, so it wasn&amp;rsquo;t possible to pass all tests and publish the package from Windows.&lt;/p>
&lt;p>The main culprit is inside the following function:&lt;/p>
&lt;pre>&lt;code class="language-javascript">function runWithInputAndExpect (input, args, expectedOutput, done) {
var command = 'echo &amp;quot;' + input.replace(/&amp;quot;/g, '\\&amp;quot;') + '&amp;quot; | node bin/cli.js ' + args;
exec(command, function callback (error, stdout, stderr) {
expect(error).to.be.a('null');
expect(stderr).to.equal('');
expect(stdout).to.equal(expectedOutput + '\n');
done(error);
});
}
&lt;/code>&lt;/pre>
&lt;p>What makes the difference between *NIX and Windows (as far as we concerned here) is how &lt;a href="https://ss64.com/nt/echo.html">&lt;code>echo&lt;/code> command&lt;/a> works. First of all, it keeps the quotes! But after we try to remove them - we will soon discover that the rabbit hole might be quite deep.&lt;/p>
&lt;p>And down the rabbit hole we go:&lt;/p></description></item></channel></rss>