Permalink
Browse files

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

  • Loading branch information...
1 parent 0b1e371 commit 2ba92f92b7876b54058d4e65e9e9197e0ba37d42 @ridiculousfish ridiculousfish committed Dec 21, 2012
Showing with 6 additions and 2 deletions.
  1. +1 −0 input.h
  2. +5 −2 reader.cpp
View
@@ -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
@@ -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))

0 comments on commit 2ba92f9

Please sign in to comment.