Index: uspace/app/bdsh/tok.c
===================================================================
--- uspace/app/bdsh/tok.c	(revision 0662451c35f4872031fe346116ad27f80b39296d)
+++ uspace/app/bdsh/tok.c	(revision 5992e0e41989c99660bb58b7c18ba9d5489d4f87)
@@ -92,9 +92,9 @@
 {
 	int rc;
-	wchar_t cur_char;
+	wchar_t next_char;
 	
 	/* Read the input line char by char and append tokens */
-	while ((cur_char = tok_get_char(tok)) != 0) {
-		if (cur_char == ' ') {
+	while ((next_char = tok_look_char(tok)) != 0) {
+		if (next_char == ' ') {
 			/* Push the token if there is any.
 			 * There may not be any pending char for a token in case
@@ -108,5 +108,5 @@
 			}
 			tok_start_token(tok, TOKTYPE_SPACE);
-			/* Eat all spaces */
+			/* Eat all the spaces */
 			while (tok_look_char(tok) == ' ') {
 				tok_push_char(tok, tok_get_char(tok));
@@ -115,7 +115,7 @@
 			
 		}
-		else if (cur_char == '|') {
-			/* Pipes are tokens that are delimiters and should be output
-			 * as a separate token
+		else if (next_char == '|') {
+			/* Pipes are tokens that are delimiters and should be
+			 * output as a separate token
 			 */
 			if (tok_pending_chars(tok)) {
@@ -128,5 +128,5 @@
 			tok_start_token(tok, TOKTYPE_PIPE);
 			
-			rc = tok_push_char(tok, '|');
+			rc = tok_push_char(tok, tok_get_char(tok));
 			if (rc != EOK) {
 				return rc;
@@ -138,9 +138,11 @@
 			}
 		}
-		else if (cur_char == '\'') {
+		else if (next_char == '\'') {
 			/* A string starts with a quote (') and ends again with a quote.
 			 * A literal quote is written as ''
 			 */
 			tok_start_token(tok, TOKTYPE_TEXT);
+			/* Eat the quote */
+			tok_get_char(tok);
 			rc = tok_finish_string(tok);
 			if (rc != EOK) {
@@ -155,5 +157,5 @@
 			 * the current token.
 			 */
-			rc = tok_push_char(tok, cur_char);
+			rc = tok_push_char(tok, tok_get_char(tok));
 			if (rc != EOK) {
 				return rc;
@@ -179,8 +181,10 @@
 {
 	int rc;
-	wchar_t cur_char;
-	
-	while ((cur_char = tok_get_char(tok)) != 0) {
-		if (cur_char == '\'') {
+	wchar_t next_char;
+	
+	while ((next_char = tok_look_char(tok)) != 0) {
+		if (next_char == '\'') {
+			/* Eat the quote */
+			tok_get_char(tok);
 			if (tok_look_char(tok) == '\'') {
 				/* Encode a single literal quote */
@@ -199,5 +203,5 @@
 		}
 		else {
-			rc = tok_push_char(tok, cur_char);
+			rc = tok_push_char(tok, tok_get_char(tok));
 			if (rc != EOK) {
 				return rc;
@@ -255,13 +259,12 @@
 	tokinfo->text = tok->outbuf + tok->outbuf_last_start;
 	tokinfo->byte_start = tok->last_in_offset;
-	tokinfo->byte_length = tok->in_offset - tok->last_in_offset - 1;
+	tokinfo->byte_length = tok->in_offset - tok->last_in_offset;
 	tokinfo->char_start = tok->last_in_char_offset;
-	tokinfo->char_length = tok->in_char_offset - tok->last_in_char_offset
-	    - 1;
+	tokinfo->char_length = tok->in_char_offset - tok->last_in_char_offset;
 	tok->outbuf_last_start = tok->outbuf_offset;
 	
 	/* We have consumed the first char of the next token already */
-	tok->last_in_offset = tok->in_offset-1;
-	tok->last_in_char_offset = tok->in_char_offset-1;
+	tok->last_in_offset = tok->in_offset;
+	tok->last_in_char_offset = tok->in_char_offset;
 	
 	return EOK;
