Fix: The leading and trailing white spaces are removed

This commit is contained in:
anseki 2015-02-10 22:39:14 +09:00
parent db8e754338
commit ca90461c57
4 changed files with 7 additions and 6 deletions

View file

@ -6,6 +6,6 @@ if "%1"=="noechoback" (
) else (
set /p LINE=<CON >CON
)
set /p DUM="%LINE%"<NUL
set /p ="'%LINE%'"<NUL
endlocal
exit /b 0

View file

@ -1,10 +1,10 @@
if [ "$1" = "noechoback" ]; then
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
# printf '\n' >/dev/tty
else
read LINE </dev/tty
IFS= read LINE </dev/tty
fi
printf '%s' "$LINE"
printf '%s' "'$LINE'"
exit 0

View file

@ -105,7 +105,7 @@ function _readlineShell(noEchoBack) {
shellPath = '/bin/sh';
args = ['-c',
'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"' +
' "' + ALGORITHM_CIPHER + '" "' + password + '"' +
' >"' + pathStdout + '") fi;' +
@ -120,6 +120,7 @@ function _readlineShell(noEchoBack) {
shellStdout =
decipher.update(fs.readFileSync(pathStdout, {encoding: 'binary'}), 'hex', encoding) +
decipher.final(encoding);
shellStdout = shellStdout.replace(/^'|'$/g, '');
}
fs.unlinkSync(pathStdout);

View file

@ -1,6 +1,6 @@
{
"name": "readline-sync",
"version": "0.5.2",
"version": "0.5.3",
"title": "readlineSync",
"description": "Synchronous Readline",
"keywords": [