diff --git a/apps/shell/shell-file.c b/apps/shell/shell-file.c index 2bab08efa..2371b3fe9 100644 --- a/apps/shell/shell-file.c +++ b/apps/shell/shell-file.c @@ -28,7 +28,7 @@ * * This file is part of the Contiki operating system. * - * $Id: shell-file.c,v 1.13 2010/02/03 20:40:00 adamdunkels Exp $ + * $Id: shell-file.c,v 1.14 2010/04/12 13:21:58 nvt-se Exp $ */ /** @@ -139,6 +139,7 @@ PROCESS_THREAD(shell_append_process, ev, data) PROCESS_THREAD(shell_write_process, ev, data) { static int fd = 0; + int r; PROCESS_EXITHANDLER(cfs_close(fd)); @@ -159,18 +160,24 @@ PROCESS_THREAD(shell_write_process, ev, data) cfs_close(fd); PROCESS_EXIT(); } - + + r = 0; if(input->len1 > 0) { - cfs_write(fd, input->data1, input->len1); + r = cfs_write(fd, input->data1, input->len1); } - if(input->len2 > 0) { - cfs_write(fd, input->data2, input->len2); + if(r >= 0 && input->len2 > 0) { + r = cfs_write(fd, input->data2, input->len2); + } + + if(r < 0) { + shell_output_str(&write_command, "write: could not write to the file", + NULL); + } else { + shell_output(&write_command, + input->data1, input->len1, + input->data2, input->len2); } - - shell_output(&write_command, - input->data1, input->len1, - input->data2, input->len2); } }