Update bgloader.js

This commit is contained in:
Namhyeon Go 2020-12-10 11:27:05 +09:00
parent 5910f93914
commit d786940ebd

View File

@ -1,12 +1,49 @@
function main() { if (!Array.prototype.map) {
var args = []; Array.prototype.map = function(fn) {
var argl = WScript.arguments.length; var rv = [];
for (var i = 0; i < argl; i++) { for (var i = 0; i < this.length; i++)
args.push(WScript.arguments(i)); rv.push(fn(this[i]));
} return rv;
};
var objShell = WScript.CreateObject("WScript.Shell");
objShell.Run(args.join(' '), 0, true);
} }
function main() {
var args = [];
var argl = WScript.arguments.length;
for (var i = 0; i < argl; i++) {
args.push(WScript.arguments(i));
}
var objShell = WScript.CreateObject("WScript.Shell");
objShell.Run(build(args), 0, true);
}
function build(cmd) {
if (typeof(cmd) === "string") {
return cmd;
} else if (typeof(cmd) === "object") {
return cmd.map(function(s) {
var regex = /[ "]/g;
if (!regex.test(s)) {
return s;
} else {
return "\"" + addslashes(s) + "\"";
}
}).join(' ');
} else {
return "";
}
}
function addslashes(s) {
return s.toString().replace(/\\/g, '\\\\').
replace(/\u0008/g, '\\b').
replace(/\t/g, '\\t').
replace(/\n/g, '\\n').
replace(/\f/g, '\\f').
replace(/\r/g, '\\r').
replace(/'/g, '\\\'').
replace(/"/g, '\\"');
};
main(); main();