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 !== '') {
|
||||
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();
|
||||
|
||||
function ttyRead() {
|
||||
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) {
|
||||
function writeTTY(text) {
|
||||
try {
|
||||
tty = tty || getFso().OpenTextFile('CONOUT$', FSO_ForWriting, true);
|
||||
tty.Write(text);
|
||||
|
@ -57,9 +45,16 @@ function ttyWrite(text) {
|
|||
}
|
||||
}
|
||||
|
||||
function getFso() {
|
||||
if (!fso) { fso = new ActiveXObject('Scripting.FileSystemObject'); }
|
||||
return fso;
|
||||
function readTTY() {
|
||||
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 readS() {
|
||||
|
@ -103,18 +98,23 @@ function scriptPW() {
|
|||
'\n' + e.description);
|
||||
WScript.Quit(1);
|
||||
}
|
||||
ttyWrite('\n');
|
||||
writeTTY('\n');
|
||||
return pw;
|
||||
}
|
||||
|
||||
function shellExec(cmd, callback) { // callback(exitCode, stdout, stderr, error)
|
||||
var wsExec, stdout = '', stderr = '', noOutput;
|
||||
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)
|
||||
var wsExec, stdout = '', stderr = '', noOutput;
|
||||
|
||||
try {
|
||||
wsExec = getShell().Exec(cmd);
|
||||
} catch (e) {
|
||||
|
@ -143,7 +143,7 @@ function shellExec(cmd, callback) { // callback(exitCode, stdout, stderr, error)
|
|||
}
|
||||
|
||||
function decodeDOS(arg) {
|
||||
return arg.replace(/#(\d+);/g, function(str, charCode) {
|
||||
return (arg + '').replace(/#(\d+);/g, function(str, charCode) {
|
||||
return String.fromCharCode(+charCode);
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue