Fix: The leading and trailing white spaces are removed
This commit is contained in:
parent
db8e754338
commit
ca90461c57
4 changed files with 7 additions and 6 deletions
|
@ -6,6 +6,6 @@ if "%1"=="noechoback" (
|
||||||
) else (
|
) else (
|
||||||
set /p LINE=<CON >CON
|
set /p LINE=<CON >CON
|
||||||
)
|
)
|
||||||
set /p DUM="%LINE%"<NUL
|
set /p ="'%LINE%'"<NUL
|
||||||
endlocal
|
endlocal
|
||||||
exit /b 0
|
exit /b 0
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
if [ "$1" = "noechoback" ]; then
|
if [ "$1" = "noechoback" ]; then
|
||||||
stty --file=/dev/tty -echo echonl || stty -F /dev/tty -echo echonl || stty -f /dev/tty -echo echonl || exit 1
|
stty --file=/dev/tty -echo echonl || stty -F /dev/tty -echo echonl || stty -f /dev/tty -echo echonl || exit 1
|
||||||
read LINE </dev/tty
|
IFS= read LINE </dev/tty
|
||||||
stty --file=/dev/tty echo -echonl || stty -F /dev/tty echo -echonl || stty -f /dev/tty echo -echonl
|
stty --file=/dev/tty echo -echonl || stty -F /dev/tty echo -echonl || stty -f /dev/tty echo -echonl
|
||||||
# printf '\n' >/dev/tty
|
# printf '\n' >/dev/tty
|
||||||
else
|
else
|
||||||
read LINE </dev/tty
|
IFS= read LINE </dev/tty
|
||||||
fi
|
fi
|
||||||
printf '%s' "$LINE"
|
printf '%s' "'$LINE'"
|
||||||
exit 0
|
exit 0
|
||||||
|
|
|
@ -105,7 +105,7 @@ function _readlineShell(noEchoBack) {
|
||||||
shellPath = '/bin/sh';
|
shellPath = '/bin/sh';
|
||||||
args = ['-c',
|
args = ['-c',
|
||||||
'DATA=`(' + shellPath + ' "' + __dirname + '/read.sh"' + optEchoBack + ')`; RTN=$?;' +
|
'DATA=`(' + shellPath + ' "' + __dirname + '/read.sh"' + optEchoBack + ')`; RTN=$?;' +
|
||||||
' if [ $RTN -eq 0 ]; then (echo $DATA |' +
|
' if [ $RTN -eq 0 ]; then (printf \'%s\' "$DATA" |' +
|
||||||
'"' + process.execPath + '" "' + __dirname + '/encrypt.js"' +
|
'"' + process.execPath + '" "' + __dirname + '/encrypt.js"' +
|
||||||
' "' + ALGORITHM_CIPHER + '" "' + password + '"' +
|
' "' + ALGORITHM_CIPHER + '" "' + password + '"' +
|
||||||
' >"' + pathStdout + '") fi;' +
|
' >"' + pathStdout + '") fi;' +
|
||||||
|
@ -120,6 +120,7 @@ function _readlineShell(noEchoBack) {
|
||||||
shellStdout =
|
shellStdout =
|
||||||
decipher.update(fs.readFileSync(pathStdout, {encoding: 'binary'}), 'hex', encoding) +
|
decipher.update(fs.readFileSync(pathStdout, {encoding: 'binary'}), 'hex', encoding) +
|
||||||
decipher.final(encoding);
|
decipher.final(encoding);
|
||||||
|
shellStdout = shellStdout.replace(/^'|'$/g, '');
|
||||||
}
|
}
|
||||||
|
|
||||||
fs.unlinkSync(pathStdout);
|
fs.unlinkSync(pathStdout);
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "readline-sync",
|
"name": "readline-sync",
|
||||||
"version": "0.5.2",
|
"version": "0.5.3",
|
||||||
"title": "readlineSync",
|
"title": "readlineSync",
|
||||||
"description": "Synchronous Readline",
|
"description": "Synchronous Readline",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
|
|
Loading…
Reference in a new issue