Fix: error of decodeDOS
when no arg
This commit is contained in:
parent
a7bb63d3e3
commit
fff855fc79
1 changed files with 25 additions and 25 deletions
|
@ -27,26 +27,14 @@ while (typeof(arg = args.shift()) === 'string') {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (typeof options.display === 'string' && options.display !== '') {
|
if (typeof options.display === 'string' && options.display !== '') {
|
||||||
ttyWrite(options.encoded ? decodeDOS(options.display) : options.display);
|
writeTTY(options.encoded ? decodeDOS(options.display) : options.display);
|
||||||
}
|
}
|
||||||
|
|
||||||
WScript.StdOut.Write("'" + (options.noEchoBack ? readS() : ttyRead()) + "'");
|
WScript.StdOut.Write("'" + (options.noEchoBack ? readS() : readTTY()) + "'");
|
||||||
|
|
||||||
WScript.Quit();
|
WScript.Quit();
|
||||||
|
|
||||||
function ttyRead() {
|
function writeTTY(text) {
|
||||||
var text;
|
|
||||||
try {
|
|
||||||
text = getFso().OpenTextFile('CONIN$', FSO_ForReading).ReadLine();
|
|
||||||
} catch (e) {
|
|
||||||
WScript.StdErr.WriteLine('TTY Read Error: ' + e.number +
|
|
||||||
'\n' + e.description);
|
|
||||||
WScript.Quit(1);
|
|
||||||
}
|
|
||||||
return text;
|
|
||||||
}
|
|
||||||
|
|
||||||
function ttyWrite(text) {
|
|
||||||
try {
|
try {
|
||||||
tty = tty || getFso().OpenTextFile('CONOUT$', FSO_ForWriting, true);
|
tty = tty || getFso().OpenTextFile('CONOUT$', FSO_ForWriting, true);
|
||||||
tty.Write(text);
|
tty.Write(text);
|
||||||
|
@ -57,9 +45,16 @@ function ttyWrite(text) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function getFso() {
|
function readTTY() {
|
||||||
if (!fso) { fso = new ActiveXObject('Scripting.FileSystemObject'); }
|
var text;
|
||||||
return fso;
|
try {
|
||||||
|
text = getFso().OpenTextFile('CONIN$', FSO_ForReading).ReadLine();
|
||||||
|
} catch (e) {
|
||||||
|
WScript.StdErr.WriteLine('TTY Read Error: ' + e.number +
|
||||||
|
'\n' + e.description);
|
||||||
|
WScript.Quit(1);
|
||||||
|
}
|
||||||
|
return text;
|
||||||
}
|
}
|
||||||
|
|
||||||
function readS() {
|
function readS() {
|
||||||
|
@ -103,18 +98,23 @@ function scriptPW() {
|
||||||
'\n' + e.description);
|
'\n' + e.description);
|
||||||
WScript.Quit(1);
|
WScript.Quit(1);
|
||||||
}
|
}
|
||||||
ttyWrite('\n');
|
writeTTY('\n');
|
||||||
return pw;
|
return pw;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getFso() {
|
||||||
|
if (!fso) { fso = new ActiveXObject('Scripting.FileSystemObject'); }
|
||||||
|
return fso;
|
||||||
|
}
|
||||||
|
|
||||||
|
function getShell() {
|
||||||
|
if (!shell) { shell = WScript.CreateObject('WScript.Shell'); }
|
||||||
|
return shell;
|
||||||
|
}
|
||||||
|
|
||||||
function shellExec(cmd, callback) { // callback(exitCode, stdout, stderr, error)
|
function shellExec(cmd, callback) { // callback(exitCode, stdout, stderr, error)
|
||||||
var wsExec, stdout = '', stderr = '', noOutput;
|
var wsExec, stdout = '', stderr = '', noOutput;
|
||||||
|
|
||||||
function getShell() {
|
|
||||||
if (!shell) { shell = WScript.CreateObject('WScript.Shell'); }
|
|
||||||
return shell;
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
wsExec = getShell().Exec(cmd);
|
wsExec = getShell().Exec(cmd);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
@ -143,7 +143,7 @@ function shellExec(cmd, callback) { // callback(exitCode, stdout, stderr, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
function decodeDOS(arg) {
|
function decodeDOS(arg) {
|
||||||
return arg.replace(/#(\d+);/g, function(str, charCode) {
|
return (arg + '').replace(/#(\d+);/g, function(str, charCode) {
|
||||||
return String.fromCharCode(+charCode);
|
return String.fromCharCode(+charCode);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue