Fix for an exception in a non-interactive shell with empty input

This commit is contained in:
ridiculousfish 2012-12-20 17:45:35 -08:00
parent 0b1e371880
commit 2ba92f92b7
2 changed files with 6 additions and 2 deletions

View File

@ -37,6 +37,7 @@ enum
R_KILL_WHOLE_LINE,
R_KILL_WORD,
R_BACKWARD_KILL_WORD,
R_BACKWARD_KILL_PATH_COMPONENT,
R_DUMP_FUNCTIONS,
R_HISTORY_TOKEN_SEARCH_BACKWARD,
R_HISTORY_TOKEN_SEARCH_FORWARD,

View File

@ -3253,8 +3253,11 @@ const wchar_t *reader_readline()
/* kill one word left */
case R_BACKWARD_KILL_WORD:
case R_BACKWARD_KILL_PATH_COMPONENT:
{
move_word(MOVE_DIR_LEFT, true /* erase */, move_word_style_path_components, last_char!=R_BACKWARD_KILL_WORD);
move_word_style_t style = (c == R_BACKWARD_KILL_PATH_COMPONENT ? move_word_style_path_components : move_word_style_punctuation);
bool newv = (last_char != R_BACKWARD_KILL_WORD && last_char != R_BACKWARD_KILL_PATH_COMPONENT);
move_word(MOVE_DIR_LEFT, true /* erase */, style, newv);
break;
}
@ -3471,7 +3474,7 @@ static int read_ni(int fd, const io_chain_t &io)
acc.insert(acc.end(), buff, buff + c);
}
const wcstring str = str2wcstring(&acc.at(0), acc.size());
const wcstring str = acc.empty() ? wcstring() : str2wcstring(&acc.at(0), acc.size());
acc.clear();
if (fclose(in_stream))