summaryrefslogtreecommitdiff
path: root/components
diff options
context:
space:
mode:
Diffstat (limited to 'components')
-rw-r--r--components/finsh/cmd.c33
-rw-r--r--components/finsh/finsh_compiler.c27
-rw-r--r--components/finsh/finsh_error.c27
-rw-r--r--components/finsh/finsh_error.h27
-rw-r--r--components/finsh/finsh_heap.c27
-rw-r--r--components/finsh/finsh_heap.h27
-rw-r--r--components/finsh/finsh_init.c27
-rw-r--r--components/finsh/finsh_node.c27
-rw-r--r--components/finsh/finsh_node.h27
-rw-r--r--components/finsh/finsh_ops.c27
-rw-r--r--components/finsh/finsh_ops.h27
-rw-r--r--components/finsh/finsh_parser.c27
-rw-r--r--components/finsh/finsh_parser.h27
-rw-r--r--components/finsh/finsh_token.c27
-rw-r--r--components/finsh/finsh_token.h27
-rw-r--r--components/finsh/finsh_var.c27
-rw-r--r--components/finsh/finsh_var.h27
-rw-r--r--components/finsh/finsh_vm.c27
-rw-r--r--components/finsh/finsh_vm.h27
-rw-r--r--components/finsh/msh.c255
-rw-r--r--components/finsh/msh.h39
-rw-r--r--components/finsh/msh_cmd.c208
-rw-r--r--components/finsh/shell.c72
-rw-r--r--components/finsh/shell.h27
-rw-r--r--components/finsh/symbol.c27
25 files changed, 1006 insertions, 141 deletions
diff --git a/components/finsh/cmd.c b/components/finsh/cmd.c
index 84a0a6f123..18f6df4a3c 100644
--- a/components/finsh/cmd.c
+++ b/components/finsh/cmd.c
@@ -1,11 +1,26 @@
/*
- * File : cmd.c
- * This file is part of RT-Thread RTOS
- * COPYRIGHT (C) 2006, RT-Thread Development Team
+ * RT-Thread finsh shell commands
*
- * The license and distribution terms for this file may be
- * found in the file LICENSE in this distribution or at
- * http://www.rt-thread.org/license/LICENSE
+ * COPYRIGHT (C) 2006 - 2013, RT-Thread Development Team
+ *
+ * This file is part of RT-Thread (http://www.rt-thread.org)
+ * Maintainer: bernard.xiong <bernard.xiong at gmail.com>
+ *
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Change Logs:
* Date Author Notes
@@ -604,6 +619,9 @@ long list(void)
index < _syscall_table_end;
FINSH_NEXT_SYSCALL(index))
{
+ /* skip the internal command */
+ if (strncpy((char*)index->name, "__", 2) == 0) continue;
+
#ifdef FINSH_USING_DESCRIPTION
rt_kprintf("%-16s -- %s\n", index->name, index->desc);
#else
@@ -693,6 +711,9 @@ void list_prefix(char *prefix)
index < _syscall_table_end;
FINSH_NEXT_SYSCALL(index))
{
+ /* skip internal command */
+ if (str_is_prefix("__", index->name) == 0) continue;
+
if (str_is_prefix(prefix, index->name) == 0)
{
if (func_cnt == 0)
diff --git a/components/finsh/finsh_compiler.c b/components/finsh/finsh_compiler.c
index 3ffdf8daec..96ccbd0b2e 100644
--- a/components/finsh/finsh_compiler.c
+++ b/components/finsh/finsh_compiler.c
@@ -1,11 +1,26 @@
/*
- * File : finsh_compiler.c
- * This file is part of RT-Thread RTOS
- * COPYRIGHT (C) 2006 - 2010, RT-Thread Development Team
+ * RT-Thread finsh shell compiler
*
- * The license and distribution terms for this file may be
- * found in the file LICENSE in this distribution or at
- * http://www.rt-thread.org/license/LICENSE
+ * COPYRIGHT (C) 2006 - 2013, RT-Thread Development Team
+ *
+ * This file is part of RT-Thread (http://www.rt-thread.org)
+ * Maintainer: bernard.xiong <bernard.xiong at gmail.com>
+ *
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Change Logs:
* Date Author Notes
diff --git a/components/finsh/finsh_error.c b/components/finsh/finsh_error.c
index 05cb8534f0..7ddab3f13b 100644
--- a/components/finsh/finsh_error.c
+++ b/components/finsh/finsh_error.c
@@ -1,11 +1,26 @@
/*
- * File : finsh_error.c
- * This file is part of RT-Thread RTOS
- * COPYRIGHT (C) 2006 - 2010, RT-Thread Development Team
+ * error number for finsh shell.
*
- * The license and distribution terms for this file may be
- * found in the file LICENSE in this distribution or at
- * http://www.rt-thread.org/license/LICENSE
+ * COPYRIGHT (C) 2013, Shanghai Real-Thread Technology Co., Ltd
+ *
+ * This file is part of RT-Thread (http://www.rt-thread.org)
+ * Maintainer: bernard.xiong <bernard.xiong at gmail.com>
+ *
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Change Logs:
* Date Author Notes
diff --git a/components/finsh/finsh_error.h b/components/finsh/finsh_error.h
index 54bc0c32e1..72bccfa9e7 100644
--- a/components/finsh/finsh_error.h
+++ b/components/finsh/finsh_error.h
@@ -1,11 +1,26 @@
/*
- * File : finsh_error.h
- * This file is part of RT-Thread RTOS
- * COPYRIGHT (C) 2006 - 2010, RT-Thread Development Team
+ * error number for finsh shell.
*
- * The license and distribution terms for this file may be
- * found in the file LICENSE in this distribution or at
- * http://www.rt-thread.org/license/LICENSE
+ * COPYRIGHT (C) 2013, Shanghai Real-Thread Technology Co., Ltd
+ *
+ * This file is part of RT-Thread (http://www.rt-thread.org)
+ * Maintainer: bernard.xiong <bernard.xiong at gmail.com>
+ *
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Change Logs:
* Date Author Notes
diff --git a/components/finsh/finsh_heap.c b/components/finsh/finsh_heap.c
index 811a111f8e..06274e79f7 100644
--- a/components/finsh/finsh_heap.c
+++ b/components/finsh/finsh_heap.c
@@ -1,11 +1,26 @@
/*
- * File : finsh_heap.c
- * This file is part of RT-Thread RTOS
- * COPYRIGHT (C) 2006 - 2010, RT-Thread Development Team
+ * heap management in finsh shell.
*
- * The license and distribution terms for this file may be
- * found in the file LICENSE in this distribution or at
- * http://www.rt-thread.org/license/LICENSE
+ * COPYRIGHT (C) 2006 - 2013, RT-Thread Development Team
+ *
+ * This file is part of RT-Thread (http://www.rt-thread.org)
+ * Maintainer: bernard.xiong <bernard.xiong at gmail.com>
+ *
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Change Logs:
* Date Author Notes
diff --git a/components/finsh/finsh_heap.h b/components/finsh/finsh_heap.h
index 73291b95f4..7ea61d47eb 100644
--- a/components/finsh/finsh_heap.h
+++ b/components/finsh/finsh_heap.h
@@ -1,11 +1,26 @@
/*
- * File : finsh_heap.h
- * This file is part of RT-Thread RTOS
- * COPYRIGHT (C) 2006 - 2010, RT-Thread Development Team
+ * heap management in finsh shell.
*
- * The license and distribution terms for this file may be
- * found in the file LICENSE in this distribution or at
- * http://www.rt-thread.org/license/LICENSE
+ * COPYRIGHT (C) 2006 - 2013, RT-Thread Development Team
+ *
+ * This file is part of RT-Thread (http://www.rt-thread.org)
+ * Maintainer: bernard.xiong <bernard.xiong at gmail.com>
+ *
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Change Logs:
* Date Author Notes
diff --git a/components/finsh/finsh_init.c b/components/finsh/finsh_init.c
index 7fe13c6a4e..f4a34791be 100644
--- a/components/finsh/finsh_init.c
+++ b/components/finsh/finsh_init.c
@@ -1,11 +1,26 @@
/*
- * File : finsh_init.c
- * This file is part of RT-Thread RTOS
- * COPYRIGHT (C) 2006 - 2010, RT-Thread Development Team
+ * Initialization procedure for finsh shell.
*
- * The license and distribution terms for this file may be
- * found in the file LICENSE in this distribution or at
- * http://www.rt-thread.org/license/LICENSE
+ * COPYRIGHT (C) 2006 - 2013, RT-Thread Development Team
+ *
+ * This file is part of RT-Thread (http://www.rt-thread.org)
+ * Maintainer: bernard.xiong <bernard.xiong at gmail.com>
+ *
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Change Logs:
* Date Author Notes
diff --git a/components/finsh/finsh_node.c b/components/finsh/finsh_node.c
index 32a890f264..6935769413 100644
--- a/components/finsh/finsh_node.c
+++ b/components/finsh/finsh_node.c
@@ -1,11 +1,26 @@
/*
- * File : finsh_node.c
- * This file is part of RT-Thread RTOS
- * COPYRIGHT (C) 2006 - 2010, RT-Thread Development Team
+ * node routines for finsh shell.
*
- * The license and distribution terms for this file may be
- * found in the file LICENSE in this distribution or at
- * http://www.rt-thread.org/license/LICENSE
+ * COPYRIGHT (C) 2006 - 2013, RT-Thread Development Team
+ *
+ * This file is part of RT-Thread (http://www.rt-thread.org)
+ * Maintainer: bernard.xiong <bernard.xiong at gmail.com>
+ *
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Change Logs:
* Date Author Notes
diff --git a/components/finsh/finsh_node.h b/components/finsh/finsh_node.h
index 26abafdda6..6dee856c83 100644
--- a/components/finsh/finsh_node.h
+++ b/components/finsh/finsh_node.h
@@ -1,11 +1,26 @@
/*
- * File : finsh_node.h
- * This file is part of RT-Thread RTOS
- * COPYRIGHT (C) 2006 - 2010, RT-Thread Development Team
+ * node routines for finsh shell.
*
- * The license and distribution terms for this file may be
- * found in the file LICENSE in this distribution or at
- * http://www.rt-thread.org/license/LICENSE
+ * COPYRIGHT (C) 2006 - 2013, RT-Thread Development Team
+ *
+ * This file is part of RT-Thread (http://www.rt-thread.org)
+ * Maintainer: bernard.xiong <bernard.xiong at gmail.com>
+ *
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Change Logs:
* Date Author Notes
diff --git a/components/finsh/finsh_ops.c b/components/finsh/finsh_ops.c
index 82802b9912..261c527556 100644
--- a/components/finsh/finsh_ops.c
+++ b/components/finsh/finsh_ops.c
@@ -1,11 +1,26 @@
/*
- * File : finsh_ops.c
- * This file is part of RT-Thread RTOS
- * COPYRIGHT (C) 2006 - 2010, RT-Thread Development Team
+ * operations for finsh shell.
*
- * The license and distribution terms for this file may be
- * found in the file LICENSE in this distribution or at
- * http://www.rt-thread.org/license/LICENSE
+ * COPYRIGHT (C) 2006 - 2013, RT-Thread Development Team
+ *
+ * This file is part of RT-Thread (http://www.rt-thread.org)
+ * Maintainer: bernard.xiong <bernard.xiong at gmail.com>
+ *
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Change Logs:
* Date Author Notes
diff --git a/components/finsh/finsh_ops.h b/components/finsh/finsh_ops.h
index 20271a4c55..4e4c5c976e 100644
--- a/components/finsh/finsh_ops.h
+++ b/components/finsh/finsh_ops.h
@@ -1,11 +1,26 @@
/*
- * File : finsh_ops.h
- * This file is part of RT-Thread RTOS
- * COPYRIGHT (C) 2006 - 2010, RT-Thread Development Team
+ * operations for finsh shell.
*
- * The license and distribution terms for this file may be
- * found in the file LICENSE in this distribution or at
- * http://www.rt-thread.org/license/LICENSE
+ * COPYRIGHT (C) 2006 - 2013, RT-Thread Development Team
+ *
+ * This file is part of RT-Thread (http://www.rt-thread.org)
+ * Maintainer: bernard.xiong <bernard.xiong at gmail.com>
+ *
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Change Logs:
* Date Author Notes
diff --git a/components/finsh/finsh_parser.c b/components/finsh/finsh_parser.c
index b4a19833cd..7f4dc822d2 100644
--- a/components/finsh/finsh_parser.c
+++ b/components/finsh/finsh_parser.c
@@ -1,11 +1,26 @@
/*
- * File : finsh_parser.c
- * This file is part of RT-Thread RTOS
- * COPYRIGHT (C) 2006 - 2010, RT-Thread Development Team
+ * script parser for finsh shell.
*
- * The license and distribution terms for this file may be
- * found in the file LICENSE in this distribution or at
- * http://www.rt-thread.org/license/LICENSE
+ * COPYRIGHT (C) 2006 - 2013, RT-Thread Development Team
+ *
+ * This file is part of RT-Thread (http://www.rt-thread.org)
+ * Maintainer: bernard.xiong <bernard.xiong at gmail.com>
+ *
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Change Logs:
* Date Author Notes
diff --git a/components/finsh/finsh_parser.h b/components/finsh/finsh_parser.h
index ef47b71c38..5f3e95b119 100644
--- a/components/finsh/finsh_parser.h
+++ b/components/finsh/finsh_parser.h
@@ -1,11 +1,26 @@
/*
- * File : finsh_parser.h
- * This file is part of RT-Thread RTOS
- * COPYRIGHT (C) 2006 - 2010, RT-Thread Development Team
+ * script parser for finsh shell.
*
- * The license and distribution terms for this file may be
- * found in the file LICENSE in this distribution or at
- * http://www.rt-thread.org/license/LICENSE
+ * COPYRIGHT (C) 2006 - 2013, RT-Thread Development Team
+ *
+ * This file is part of RT-Thread (http://www.rt-thread.org)
+ * Maintainer: bernard.xiong <bernard.xiong at gmail.com>
+ *
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Change Logs:
* Date Author Notes
diff --git a/components/finsh/finsh_token.c b/components/finsh/finsh_token.c
index 1965bc5400..9bc808fc9e 100644
--- a/components/finsh/finsh_token.c
+++ b/components/finsh/finsh_token.c
@@ -1,11 +1,26 @@
/*
- * File : finsh_token.c
- * This file is part of RT-Thread RTOS
- * COPYRIGHT (C) 2006 - 2010, RT-Thread Development Team
+ * token lex for finsh shell.
*
- * The license and distribution terms for this file may be
- * found in the file LICENSE in this distribution or at
- * http://www.rt-thread.org/license/LICENSE
+ * COPYRIGHT (C) 2006 - 2013, RT-Thread Development Team
+ *
+ * This file is part of RT-Thread (http://www.rt-thread.org)
+ * Maintainer: bernard.xiong <bernard.xiong at gmail.com>
+ *
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Change Logs:
* Date Author Notes
diff --git a/components/finsh/finsh_token.h b/components/finsh/finsh_token.h
index cde596b1bf..4b84521874 100644
--- a/components/finsh/finsh_token.h
+++ b/components/finsh/finsh_token.h
@@ -1,11 +1,26 @@
/*
- * File : finsh_token.h
- * This file is part of RT-Thread RTOS
- * COPYRIGHT (C) 2006 - 2010, RT-Thread Development Team
+ * token lex for finsh shell.
*
- * The license and distribution terms for this file may be
- * found in the file LICENSE in this distribution or at
- * http://www.rt-thread.org/license/LICENSE
+ * COPYRIGHT (C) 2006 - 2013, RT-Thread Development Team
+ *
+ * This file is part of RT-Thread (http://www.rt-thread.org)
+ * Maintainer: bernard.xiong <bernard.xiong at gmail.com>
+ *
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Change Logs:
* Date Author Notes
diff --git a/components/finsh/finsh_var.c b/components/finsh/finsh_var.c
index 8429f6f21c..cd1e089964 100644
--- a/components/finsh/finsh_var.c
+++ b/components/finsh/finsh_var.c
@@ -1,11 +1,26 @@
/*
- * File : finsh_var.c
- * This file is part of RT-Thread RTOS
- * COPYRIGHT (C) 2006 - 2010, RT-Thread Development Team
+ * Variable implementation in finsh shell.
*
- * The license and distribution terms for this file may be
- * found in the file LICENSE in this distribution or at
- * http://www.rt-thread.org/license/LICENSE
+ * COPYRIGHT (C) 2006 - 2013, RT-Thread Development Team
+ *
+ * This file is part of RT-Thread (http://www.rt-thread.org)
+ * Maintainer: bernard.xiong <bernard.xiong at gmail.com>
+ *
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Change Logs:
* Date Author Notes
diff --git a/components/finsh/finsh_var.h b/components/finsh/finsh_var.h
index fe9a9c4de4..3d10b9d7e0 100644
--- a/components/finsh/finsh_var.h
+++ b/components/finsh/finsh_var.h
@@ -1,11 +1,26 @@
/*
- * File : finsh_var.h
- * This file is part of RT-Thread RTOS
- * COPYRIGHT (C) 2006 - 2010, RT-Thread Development Team
+ * Variable implementation in finsh shell.
*
- * The license and distribution terms for this file may be
- * found in the file LICENSE in this distribution or at
- * http://www.rt-thread.org/license/LICENSE
+ * COPYRIGHT (C) 2006 - 2013, RT-Thread Development Team
+ *
+ * This file is part of RT-Thread (http://www.rt-thread.org)
+ * Maintainer: bernard.xiong <bernard.xiong at gmail.com>
+ *
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Change Logs:
* Date Author Notes
diff --git a/components/finsh/finsh_vm.c b/components/finsh/finsh_vm.c
index 6b24b70f24..66da5a14b0 100644
--- a/components/finsh/finsh_vm.c
+++ b/components/finsh/finsh_vm.c
@@ -1,11 +1,26 @@
/*
- * File : finsh_vm.c
- * This file is part of RT-Thread RTOS
- * COPYRIGHT (C) 2006 - 2010, RT-Thread Development Team
+ * Virtual machine finsh shell.
*
- * The license and distribution terms for this file may be
- * found in the file LICENSE in this distribution or at
- * http://www.rt-thread.org/license/LICENSE
+ * COPYRIGHT (C) 2006 - 2013, RT-Thread Development Team
+ *
+ * This file is part of RT-Thread (http://www.rt-thread.org)
+ * Maintainer: bernard.xiong <bernard.xiong at gmail.com>
+ *
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Change Logs:
* Date Author Notes
diff --git a/components/finsh/finsh_vm.h b/components/finsh/finsh_vm.h
index e4aeaa5530..6291ea9cc7 100644
--- a/components/finsh/finsh_vm.h
+++ b/components/finsh/finsh_vm.h
@@ -1,11 +1,26 @@
/*
- * File : finsh_vm.h
- * This file is part of RT-Thread RTOS
- * COPYRIGHT (C) 2006 - 2010, RT-Thread Development Team
+ * Virtual machine finsh shell.
*
- * The license and distribution terms for this file may be
- * found in the file LICENSE in this distribution or at
- * http://www.rt-thread.org/license/LICENSE
+ * COPYRIGHT (C) 2006 - 2013, RT-Thread Development Team
+ *
+ * This file is part of RT-Thread (http://www.rt-thread.org)
+ * Maintainer: bernard.xiong <bernard.xiong at gmail.com>
+ *
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Change Logs:
* Date Author Notes
diff --git a/components/finsh/msh.c b/components/finsh/msh.c
new file mode 100644
index 0000000000..f8d1a4fabc
--- /dev/null
+++ b/components/finsh/msh.c
@@ -0,0 +1,255 @@
+/*
+ * RT-Thread module shell implementation.
+ *
+ * COPYRIGHT (C) 2013, Shanghai Real-Thread Technology Co., Ltd
+ *
+ * This file is part of RT-Thread (http://www.rt-thread.org)
+ * Maintainer: bernard.xiong <bernard.xiong at gmail.com>
+ *
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Change Logs:
+ * Date Author Notes
+ * 2013-03-30 Bernard the first verion for FinSH
+ */
+
+#include "msh.h"
+#include <finsh.h>
+#include <shell.h>
+
+#define RT_FINSH_ARG_MAX 10
+typedef int (*cmd_function_t)(int argc, char** argv);
+
+#ifdef FINSH_USING_MSH
+#ifdef FINSH_USING_MSH_DEFAULT
+static rt_bool_t __msh_state = RT_TRUE;
+#else
+static rt_bool_t __msh_state = RT_FALSE;
+#endif
+rt_bool_t msh_is_used(void)
+{
+ return __msh_state;
+}
+
+static int msh_exit(int argc, char** argv)
+{
+ /* return to finsh shell mode */
+ __msh_state = RT_FALSE;
+
+ return 0;
+}
+FINSH_FUNCTION_EXPORT_ALIAS(msh_exit, __cmd_exit, return to RT-Thread shell mode.);
+
+static int msh_enter(void)
+{
+ /* enter module shell mode */
+ __msh_state = RT_TRUE;
+ return 0;
+}
+FINSH_FUNCTION_EXPORT_ALIAS(msh_enter, msh, use module shell);
+
+int msh_help(int argc, char** argv)
+{
+ rt_kprintf("RT-Thread shell commands:\n");
+ {
+ struct finsh_syscall *index;
+
+ for (index = _syscall_table_begin;
+ index < _syscall_table_end;
+ FINSH_NEXT_SYSCALL(index))
+ {
+ if (strncmp(index->name, "__cmd_", 6) != 0) continue;
+
+ rt_kprintf("%s ", &index->name[6]);
+ }
+ }
+ rt_kprintf("\n");
+
+ return 0;
+}
+FINSH_FUNCTION_EXPORT_ALIAS(msh_help, __cmd_help, "RT-Thread shell help.");
+
+static int msh_split(char* cmd, rt_size_t length, char* argv[RT_FINSH_ARG_MAX])
+{
+ char *ptr;
+ rt_size_t position;
+ rt_size_t argc;
+
+ ptr = cmd;
+ position = 0; argc = 0;
+
+ while (position < length)
+ {
+ /* strip bank and tab */
+ while ((*ptr == ' ' || *ptr == '\t') && position < length)
+ {
+ *ptr = '\0';
+ ptr ++; position ++;
+ }
+ if (position >= length) break;
+
+ /* handle string */
+ if (*ptr == '"')
+ {
+ ptr ++; position ++;
+ argv[argc] = ptr; argc ++;
+
+ /* skip this string */
+ while (*ptr != '"' && position < length)
+ {
+ if (*ptr == '\\')
+ {
+ if (*(ptr + 1) == '"')
+ {
+ ptr ++; position ++;
+ }
+ }
+ ptr ++; position ++;
+ }
+ if (position >= length) break;
+
+ /* skip '"' */
+ *ptr = '\0'; ptr ++; position ++;
+ }
+ else
+ {
+ argv[argc] = ptr;
+ argc ++;
+ while ((*ptr != ' ' && *ptr != '\t') && position < length)
+ {
+ ptr ++; position ++;
+ }
+ if (position >= length) break;
+ }
+ }
+
+ return argc;
+}
+
+static cmd_function_t msh_get_cmd(char *cmd)
+{
+ struct finsh_syscall *index;
+ cmd_function_t cmd_func = RT_NULL;
+
+ for (index = _syscall_table_begin;
+ index < _syscall_table_end;
+ FINSH_NEXT_SYSCALL(index))
+ {
+ if (strncmp(index->name, "__cmd_", 6) != 0) continue;
+
+ if (strcmp(&index->name[6], cmd) == 0)
+ {
+ cmd_func = (cmd_function_t)index->func;
+ break;
+ }
+ }
+
+ return cmd_func;
+}
+
+int msh_exec(char* cmd, rt_size_t length)
+{
+ int argc;
+ char *argv[RT_FINSH_ARG_MAX];
+
+ cmd_function_t cmd_func;
+
+ memset(argv, 0x00, sizeof(argv));
+ argc = msh_split(cmd, length, argv);
+ if (argc == 0) return -1;
+
+ /* get command in internal commands */
+ cmd_func = msh_get_cmd(argv[0]);
+ if (cmd_func == RT_NULL)
+ {
+ rt_kprintf("%s: command not found\n", argv[0]);
+ return -1;
+ }
+
+ /* exec this command */
+ return cmd_func(argc, argv);
+}
+
+static int str_common(const char *str1, const char *str2)
+{
+ const char *str = str1;
+
+ while ((*str != 0) && (*str2 != 0) && (*str == *str2))
+ {
+ str ++;
+ str2 ++;
+ }
+
+ return (str - str1);
+}
+
+void msh_auto_complete(char *prefix)
+{
+ rt_uint16_t func_cnt;
+ int length, min_length;
+ const char *name_ptr, *cmd_name;
+ struct finsh_syscall *index;
+
+ func_cnt = 0;
+ min_length = 0;
+ name_ptr = RT_NULL;
+
+ if (*prefix == '\0')
+ {
+ msh_help(0, RT_NULL);
+ return;
+ }
+
+ /* checks in internal command */
+ {
+ for (index = _syscall_table_begin; index < _syscall_table_end; FINSH_NEXT_SYSCALL(index))
+ {
+ /* skip finsh shell function */
+ if (strncmp(index->name, "__cmd_", 6) != 0) continue;
+
+ cmd_name = (const char*) &index->name[6];
+ if (strncmp(prefix, cmd_name, strlen(prefix)) == 0)
+ {
+ if (func_cnt == 0)
+ {
+ /* set name_ptr */
+ name_ptr = cmd_name;
+
+ /* set initial length */
+ min_length = strlen(name_ptr);
+ }
+
+ func_cnt ++;
+
+ length = str_common(name_ptr, cmd_name);
+ if (length < min_length)
+ min_length = length;
+
+ rt_kprintf("%s\n", cmd_name);
+ }
+ }
+ }
+
+ /* auto complete string */
+ if (name_ptr != NULL)
+ {
+ rt_strncpy(prefix, name_ptr, min_length);
+ }
+
+ return ;
+}
+#endif
diff --git a/components/finsh/msh.h b/components/finsh/msh.h
new file mode 100644
index 0000000000..959170da3d
--- /dev/null
+++ b/components/finsh/msh.h
@@ -0,0 +1,39 @@
+/*
+ * RT-Thread module shell implementation.
+ *
+ * COPYRIGHT (C) 2013, Shanghai Real-Thread Technology Co., Ltd
+ *
+ * This file is part of RT-Thread (http://www.rt-thread.org)
+ * Maintainer: bernard.xiong <bernard.xiong at gmail.com>
+ *
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Change Logs:
+ * Date Author Notes
+ * 2013-03-30 Bernard the first verion for FinSH
+ */
+
+#ifndef __M_SHELL__
+#define __M_SHELL__
+
+#include <rtthread.h>
+
+rt_bool_t msh_is_used(void);
+int msh_exec(char* cmd, rt_size_t length);
+void msh_auto_complete(char *prefix);
+
+#endif
diff --git a/components/finsh/msh_cmd.c b/components/finsh/msh_cmd.c
new file mode 100644
index 0000000000..8fe3a60f5c
--- /dev/null
+++ b/components/finsh/msh_cmd.c
@@ -0,0 +1,208 @@
+/*
+ * internal commands for RT-Thread module shell
+ *
+ * COPYRIGHT (C) 2013, Shanghai Real-Thread Technology Co., Ltd
+ *
+ * This file is part of RT-Thread (http://www.rt-thread.org)
+ * Maintainer: bernard.xiong <bernard.xiong at gmail.com>
+ *
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Change Logs:
+ * Date Author Notes
+ * 2013-03-30 Bernard the first verion for FinSH
+ */
+
+#include <rtthread.h>
+#include <finsh.h>
+
+#include "msh.h"
+
+#ifdef FINSH_USING_MSH
+#ifdef RT_USING_DFS
+#include <dfs_posix.h>
+
+#ifdef DFS_USING_WORKDIR
+extern char working_directory[];
+#endif
+
+int cmd_ps(int argc, char** argv)
+{
+ extern long list_thread(void);
+
+ list_thread();
+ return 0;
+}
+FINSH_FUNCTION_EXPORT_ALIAS(cmd_ps, __cmd_ps, "list threads in the system");
+
+int cmd_i(int argc, char** argv)
+{
+ return cmd_ps(argc, argv);
+}
+FINSH_FUNCTION_EXPORT_ALIAS(cmd_i, __cmd_i, "list threads in the system");
+
+int cmd_time(int argc, char** argv)
+{
+ return 0;
+}
+FINSH_FUNCTION_EXPORT_ALIAS(cmd_time, __cmd_time, "exec command with time");
+
+int cmd_free(int argc, char** argv)
+{
+ extern void list_mem(void);
+
+ list_mem();
+ return 0;
+}
+FINSH_FUNCTION_EXPORT_ALIAS(cmd_free, __cmd_free, "show the memory usage in the system");
+
+int cmd_ls(int argc, char** argv)
+{
+ extern void ls(const char *pathname);
+
+ if (argc == 1)
+ {
+#ifdef DFS_USING_WORKDIR
+ ls(working_directory);
+#else
+ ls("/");
+#endif
+ }
+ else
+ {
+ ls(argv[1]);
+ }
+
+ return 0;
+}
+FINSH_FUNCTION_EXPORT_ALIAS(cmd_ls, __cmd_ls, "List information about the FILEs.");
+
+int cmd_cp(int argc, char** argv)
+{
+ void copy(const char *src, const char *dst);
+
+ if (argc != 3)
+ {
+ rt_kprintf("Usage: cp SOURCE DEST\n");
+ rt_kprintf("Copy SOURCE to DEST.\n");
+ }
+ else
+ {
+ copy(argv[1], argv[2]);
+ }
+
+ return 0;
+}
+FINSH_FUNCTION_EXPORT_ALIAS(cmd_cp, __cmd_cp, "Copy SOURCE to DEST.");
+
+int cmd_mv(int argc, char** argv)
+{
+ if (argc != 3)
+ {
+ rt_kprintf("Usage: mv SOURCE DEST\n");
+ rt_kprintf("Rename SOURCE to DEST, or move SOURCE(s) to DIRECTORY.\n");
+ }
+ else
+ {
+ rt_kprintf("%s => %s\n", argv[1], argv[2]);
+ }
+
+ return 0;
+}
+FINSH_FUNCTION_EXPORT_ALIAS(cmd_mv, __cmd_mv, "Rename SOURCE to DEST.");
+
+int cmd_cat(int argc, char** argv)
+{
+ int index;
+ extern void cat(const char* filename);
+
+ if (argc == 1)
+ {
+ rt_kprintf("Usage: cat [FILE]...\n");
+ rt_kprintf("Concatenate FILE(s)\n");
+ return 0;
+ }
+
+ for (index = 1; index < argc; index ++)
+ {
+ cat(argv[index]);
+ }
+
+ return 0;
+}
+FINSH_FUNCTION_EXPORT_ALIAS(cmd_cat, __cmd_cat, "Concatenate FILE(s)");
+
+int cmd_rm(int argc, char** argv)
+{
+ int index;
+
+ if (argc == 1)
+ {
+ rt_kprintf("Usage: rm FILE...\n");
+ rt_kprintf("Remove (unlink) the FILE(s).\n");
+ return 0;
+ }
+
+ for (index = 1; index < argc; index ++)
+ {
+ unlink(argv[index]);
+ }
+
+ return 0;
+}
+FINSH_FUNCTION_EXPORT_ALIAS(cmd_rm, __cmd_rm, "Remove (unlink) the FILE(s).");
+
+int cmd_cd(int argc, char** argv)
+{
+ if (argc == 1)
+ {
+ rt_kprintf("%s\n", working_directory);
+ }
+ else if (argc == 2)
+ {
+ chdir(argv[1]);
+ }
+
+ return 0;
+}
+FINSH_FUNCTION_EXPORT_ALIAS(cmd_cd, __cmd_cd, Change the shell working directory.);
+
+int cmd_pwd(int argc, char** argv)
+{
+ rt_kprintf("%s\n", working_directory);
+ return 0;
+}
+FINSH_FUNCTION_EXPORT_ALIAS(cmd_pwd, __cmd_pwd, Print the name of the current working directory.);
+
+int cmd_mkdir(int argc, char** argv)
+{
+ if (argc == 1)
+ {
+ rt_kprintf("Usage: mkdir [OPTION] DIRECTORY\n");
+ rt_kprintf("Create the DIRECTORY, if they do not already exist.\n");
+ }
+ else
+ {
+ mkdir(argv[1], 0);
+ }
+
+ return 0;
+}
+FINSH_FUNCTION_EXPORT_ALIAS(cmd_mkdir, __cmd_mkdir, Create the DIRECTORY.);
+
+#endif
+#endif
diff --git a/components/finsh/shell.c b/components/finsh/shell.c
index 82cbc68485..53932aa5a0 100644
--- a/components/finsh/shell.c
+++ b/components/finsh/shell.c
@@ -1,15 +1,30 @@
/*
- * File : shell.c
- * This file is part of RT-Thread RTOS
- * COPYRIGHT (C) 2006, RT-Thread Development Team
+ * shell implementation for finsh shell.
*
- * The license and distribution terms for this file may be
- * found in the file LICENSE in this distribution or at
- * http://www.rt-thread.org/license/LICENSE
+ * COPYRIGHT (C) 2006 - 2013, RT-Thread Development Team
+ *
+ * This file is part of RT-Thread (http://www.rt-thread.org)
+ * Maintainer: bernard.xiong <bernard.xiong at gmail.com>
+ *
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Change Logs:
* Date Author Notes
- * 2006-04-30 Bernard the first verion for FinSH
+ * 2006-04-30 Bernard the first version for FinSH
* 2006-05-08 Bernard change finsh thread stack to 2048
* 2006-06-03 Bernard add support for skyeye
* 2006-09-24 Bernard remove the code related with hardware
@@ -26,6 +41,10 @@
#include "finsh.h"
#include "shell.h"
+#ifdef FINSH_USING_MSH
+#include "msh.h"
+#endif
+
#ifdef _WIN32
#include <stdio.h> /* for putchar */
#endif
@@ -192,7 +211,17 @@ void finsh_auto_complete(char* prefix)
extern void list_prefix(char* prefix);
rt_kprintf("\n");
- list_prefix(prefix);
+#ifdef FINSH_USING_MSH
+ if (msh_is_used() == RT_TRUE)
+ {
+ msh_auto_complete(prefix);
+ }
+ else
+#endif
+ {
+ list_prefix(prefix);
+ }
+
rt_kprintf("%s%s", FINSH_PROMPT, prefix);
}
@@ -420,15 +449,28 @@ void finsh_thread_entry(void* parameter)
/* handle end of line, break */
if (ch == '\r' || ch == '\n')
{
- /* change to ';' and break */
- shell->line[shell->line_position] = ';';
+#ifdef FINSH_USING_MSH
+ if (msh_is_used() == RT_TRUE && shell->line_position != 0)
+ {
+ rt_kprintf("\n");
+ msh_exec(shell->line, shell->line_position);
+ #ifdef FINSH_USING_HISTORY
+ finsh_push_history(shell);
+ #endif
+ }
+ else
+#endif
+ {
+ /* add ';' and run the command line */
+ shell->line[shell->line_position] = ';';
- #ifdef FINSH_USING_HISTORY
- finsh_push_history(shell);
- #endif
+ #ifdef FINSH_USING_HISTORY
+ finsh_push_history(shell);
+ #endif
- if (shell->line_position != 0) finsh_run_line(&shell->parser, shell->line);
- else rt_kprintf("\n");
+ if (shell->line_position != 0) finsh_run_line(&shell->parser, shell->line);
+ else rt_kprintf("\n");
+ }
rt_kprintf(FINSH_PROMPT);
memset(shell->line, 0, sizeof(shell->line));
diff --git a/components/finsh/shell.h b/components/finsh/shell.h
index e14466018b..ff768d4c66 100644
--- a/components/finsh/shell.h
+++ b/components/finsh/shell.h
@@ -1,11 +1,26 @@
/*
- * File : shell.h
- * This file is part of RT-Thread RTOS
- * COPYRIGHT (C) 2006 - 2011, RT-Thread Development Team
+ * shell implementation for finsh shell.
*
- * The license and distribution terms for this file may be
- * found in the file LICENSE in this distribution or at
- * http://www.rt-thread.org/license/LICENSE
+ * COPYRIGHT (C) 2006 - 2013, RT-Thread Development Team
+ *
+ * This file is part of RT-Thread (http://www.rt-thread.org)
+ * Maintainer: bernard.xiong <bernard.xiong at gmail.com>
+ *
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Change Logs:
* Date Author Notes
diff --git a/components/finsh/symbol.c b/components/finsh/symbol.c
index 4d50a19470..5aedd91d61 100644
--- a/components/finsh/symbol.c
+++ b/components/finsh/symbol.c
@@ -1,11 +1,26 @@
/*
- * File : symbol.c
- * This file is part of RT-Thread RTOS
- * COPYRIGHT (C) 2006 - 2010, RT-Thread Development Team
+ * symbols in finsh shell.
*
- * The license and distribution terms for this file may be
- * found in the file LICENSE in this distribution or at
- * http://www.rt-thread.org/license/LICENSE
+ * COPYRIGHT (C) 2006 - 2013, RT-Thread Development Team
+ *
+ * This file is part of RT-Thread (http://www.rt-thread.org)
+ * Maintainer: bernard.xiong <bernard.xiong at gmail.com>
+ *
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Change Logs:
* Date Author Notes