Skip to content

Instantly share code, notes, and snippets.

@paulbaumgart
Created April 26, 2010 20:29
Show Gist options
  • Save paulbaumgart/379859 to your computer and use it in GitHub Desktop.
Save paulbaumgart/379859 to your computer and use it in GitHub Desktop.
// Work-around for OS.command that isn't compatible with narwhal-jsc.
// This should be removed if a fix is merged into the mainline narwhal-jsc.
try
{
OS.command("");
}
catch (e)
{
OS.command = function(command)
{
var newCommand = command + " 2>/dev/null",
process = OS.popen(newCommand),
results = [],
tmpResult;
do
{
tmpResult = process.stdout.read();
results.push(tmpResult);
}
while (tmpResult !== "");
var status = process.wait();
if (status !== 0)
throw new Error("command: \"" + command + "\" returned status: " + status);
return results.join("");
};
}
try
{
print(OS.command("false"));
}
catch (e)
{
print(e);
}
print(OS.command("for i in {1..10000}; do echo $i; done;"));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment