Index: uspace/app/bdsh/tok.c
===================================================================
--- uspace/app/bdsh/tok.c	(revision 42a619b240617c4f0e4dd04ddf2366f3c5a0709a)
+++ uspace/app/bdsh/tok.c	(revision 7dcb7981f0dce48017dcb71e0a8e61941a5e5e4b)
@@ -50,9 +50,12 @@
  * @param max_tokens number of elements of the out_tokens array
  */
-int tok_init(tokenizer_t *tok, char *input, char **out_tokens,
+int tok_init(tokenizer_t *tok, char *input, token_t *out_tokens,
     size_t max_tokens)
 {	
 	tok->in = input;
 	tok->in_offset = 0;
+	tok->last_in_offset = 0;
+	tok->in_char_offset = 0;
+	tok->last_in_char_offset = 0;
 	
 	tok->outtok = out_tokens;
@@ -201,4 +204,5 @@
 wchar_t tok_get_char(tokenizer_t *tok)
 {
+	tok->in_char_offset++;
 	return str_decode(tok->in, &tok->in_offset, STR_NO_LIMIT);
 }
@@ -207,7 +211,9 @@
 wchar_t tok_look_char(tokenizer_t *tok)
 {
-	size_t old_offset = tok->in_offset;
+	off_t old_offset = tok->in_offset;
+	off_t old_char_offset = tok->in_char_offset;
 	wchar_t ret = tok_get_char(tok);
 	tok->in_offset = old_offset;
+	tok->in_char_offset = old_char_offset;
 	return ret;
 }
@@ -231,6 +237,17 @@
 	
 	tok->outbuf[tok->outbuf_offset++] = 0;
-	tok->outtok[tok->outtok_offset++] = tok->outbuf + tok->outbuf_last_start;
+	token_t *tokinfo = &tok->outtok[tok->outtok_offset++]
+	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.char_start = tok->last_in_char_offset;
+	tokinfo.char_length = tok->in_char_offset - tok->last_in_char_offset
+	    - 1;
+	tok->outtok[tok->outtok_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;
 	
 	return EOK;
Index: uspace/app/bdsh/tok.h
===================================================================
--- uspace/app/bdsh/tok.h	(revision 42a619b240617c4f0e4dd04ddf2366f3c5a0709a)
+++ uspace/app/bdsh/tok.h	(revision 7dcb7981f0dce48017dcb71e0a8e61941a5e5e4b)
@@ -30,7 +30,25 @@
 #define TOK_H
 
+typedef enum {
+	TOKTYPE_TEXT,
+	TOKTYPE_PIPE,
+	TOKTYPE_SPACE
+} token_type_t;
+
+typedef struct {
+	char *text;
+	off_t byte_start;
+	off_t char_start;
+	size_t byte_length;
+	size_t char_length;
+ 	token_type_t type;
+} token_t;
+
 typedef struct {
 	char *in;
-	size_t in_offset;
+	off_t in_offset;
+	off_t last_in_offset;
+	off_t in_char_offset;
+	off_t last_in_char_offset;
 	
 	char *outbuf;
@@ -39,10 +57,10 @@
 	size_t outbuf_last_start;
 	
-	char **outtok;
+	token_t *outtok;
 	size_t outtok_offset;
 	size_t outtok_size;
 } tokenizer_t;
 
-extern int tok_init(tokenizer_t *, char *, char **, size_t);
+extern int tok_init(tokenizer_t *, char *, token_t *, size_t);
 extern void tok_fini(tokenizer_t *);
 extern int tok_tokenize(tokenizer_t *);
