LwSHELL is lightweight, platform independent, command line shell for embedded systems.

Related tags

CLI lwshell
Overview

Lightweight shell

LwSHELL is lightweight, platform independent, command line shell for embedded systems. It targets communication with embedded systems from remote terminal to quickly send commands and the retrieve data from the device.

Read first: Documentation

Features

  • Lightweight commands shell for embedded systems
  • Platform independent and very easy to port
    • Development of library under Win32 platform
  • Written in C language (C99)
  • No dynamic allocation, maximum number of commands assigned at compile time
  • Highly configurable
  • Simple help-text with cmd -v option
  • User friendly MIT license

Contribute

Fresh contributions are always welcome. Simple instructions to proceed::

  1. Fork Github repository
  2. Respect C style & coding rules used by the library
  3. Create a pull request to develop branch with new features or bug fixes

Alternatively you may:

  1. Report a bug
  2. Ask for a feature request
Comments
  • input buffer overflow

    input buffer overflow

    @MaJerle - I can do a pull request for the below issue, but want to know your preference first.

    when the input buffer is full, we get an overflow while parsing the args:

                } else {
                    lw->argv[lw->argc++] = str;     /* Set start of argument directly on character */
                    while (*str != ' ' && *str != '\0') {
                        if (*str == '"') {          /* Quote should not be here... */
                            *str = '\0';            /* ...add NULL termination to end token */
                        }
                        ++str;
                    }
                    *str = '\0';
                    ++str;   /* <<<==== here str increment over the input buff when the above while stop on the last byte of the buff */
                }
    

    Since this is a light shell, I assume you want to keep performance as good as possible:

    • the first option is less intuitive, but it just adds one byte to the memory usage :)
    • the second option adds more execution code :(

    1. add 2 extra bytes (instead of +1) to the input buffer and change the ADD macro. this way we guarantee an extra NULL at the end:

    char buff[LWSHELL_CFG_MAX_INPUT_LEN + 2]; /*!< Shell command input buffer */

     /* Add character to instance */
    #define LWSHELL_ADD_CH(lw, ch)      do {            \
        if ((lw)->buff_ptr < (LWSHELL_ARRAYSIZE(lw->buff) - 2)) {   \
            (lw)->buff[(lw)->buff_ptr] = ch;            \
            (lw)->buff[++(lw)->buff_ptr] = '\0';        \
        }                                               \
    } while (0)
    
    

    2. Stop the loop with some pointer calculation:

                /* Check for number of arguments */
                if (lw->argc == LWSHELL_ARRAYSIZE(lw->argv)) {
                    break;
                }
    
                /* Consume all input buffer... */
                if (str - lw->buff >= sizeof((lw)->buff)) {
                    break;
                }
            }
    
    opened by hagaigold 8
  • carriage return line feed while cmd handling

    carriage return line feed while cmd handling

    Hi,

    Really great simple shell but for me there is one handling really bad. So if as an example the user inputs some command (calc) using a terminal which gives /r/n at the end of the command then the input string looks like this

    calc 1 2/r/n

    So then in the handle function of calc i do some printing to the terminal. But after that /r and /n will be printed also i think that is not a behavior for everyone.

    So a quick fix for me was change parse input. And if the parser found some command i will ignore the output of CR or LF but maybe there is a better solution.

    best regards, mathias

    opened by mgiaco 6
  • Unnecessary/duplicate argc clear

    Unnecessary/duplicate argc clear

        /* Must be more than `1` character since we have to include end of line */
        if (lw->buff_ptr > 0) {
            /* Set default values */
            lw->argc = 0;
            lw->argv[0] = lw->buff;
    
            /* Process complete input */
            str = lw->buff;
    
            /* Process complete string */
            lw->argc = 0;
            while (*str != '\0') {
    

    Line 112 in lwshell.c

    You clear argc, then clear it again before anything could have changed.

    opened by jnz86 2
  • fix delete character from buffer

    fix delete character from buffer

    buff_ptr point to the end of the input buffer which is NULL, so it should be decreased before deleting the last character. I added a test option to test it by using a non-canonical input mode

    opened by hagaigold 2
  • declare lwshell_cmd_t in header file

    declare lwshell_cmd_t in header file

    Moving the struct to the header file would allow the application writer to declare their commands with it.

    Here I declared my own struct: https://github.com/Ballen7/money-printer/blob/dev/apps/tempo/src/console.c

    opened by Ballen7 1
  • Request: Add _ex feature to address multiple shells

    Request: Add _ex feature to address multiple shells

    As topic.

    I have a primary shell I use for on-module CLI access, as well as another shell that allows access to a bootloader CLI of off-board module. This latter terminal has different inputs and a tokenizer.

    It would be nice to set both shells up differently and use this framework to address either.

    opened by jnz86 0
Releases(v1.2.0)
Owner
Tilen Majerle
Trust is a dangerous game
Tilen Majerle
led is a line-oriented text editor in command line

led is a line-oriented text editor in command line. This editor is similar to the standard program on unix systems - GNU ed. But i'm not going to make an exact clone of that program, it's just a pet project.

Artem Mironov 16 Dec 27, 2022
Simple command line tool that processes image files using the FidelityFX Super Resolution (FSR) or Contrast Adaptive Sharpening (CAS) shader systems.

Simple command line tool that processes image files using the FidelityFX Super Resolution (FSR) or Contrast Adaptive Sharpening (CAS) shader systems.

GPUOpen Effects 190 Dec 12, 2022
Lightweight C++ command line option parser

Release versions Note that master is generally a work in progress, and you probably want to use a tagged release version. Version 3 breaking changes I

null 3.3k Dec 30, 2022
crypted admin shell: SSH-like strong crypto remote admin shell for Linux, BSD, Android, Solaris and OSX

crypted admin shell: SSH-like strong crypto remote admin shell for Linux, BSD, Android, Solaris and OSX

Sebastian 135 Jan 2, 2023
simple c program thats spawns a shell wants executed, this shell will detect your os and upon entering will erase or reset the system V1.0

kill-shell simple c program thats spawns a shell wants executed, this shell will detect your os and upon entering will erase or reset the system V1.0

RE43P3R 1 Oct 18, 2021
Pine's ok shell, a shell in C++

POSH Pine's ok shell, a shell in C++ Answers to questions nobody asked. "Is your name Pine?" No, although that would be neat. Pine is supposed to be a

Boops-Boops 1 Nov 6, 2021
SimPle SHell - minimalist Unix interactive shell written in a single C file

SimPle SHell - minimalist Unix interactive shell written in a single C file. The shell does not support scripting yet and is in an early stage of development. If you notice any bug, please open an issue on github.

sewe2000 2 Oct 24, 2021
EAMain provides a multi-platform entry point used for platforms that don't support console output, return codes and command-line arguments.

EAMain provides a multi-platform entry point used for platforms that don't support console output, return codes and command-line arguments.

Electronic Arts 34 Oct 1, 2022
Yori is a CMD replacement shell that supports backquotes, job control, and improves tab completion, file matching, aliases, command history, and more.

Yori is a CMD replacement shell that supports backquotes, job control, and improves tab completion, file matching, aliases, command history, and more.

Malcolm Smith 1.1k Dec 30, 2022
CS140E: embedded operating systems

CS140E: embedded operating systems (Engler, Winter, 2022) This is a lab-based class with no explicit lectures. We will do two three-to-five hour labs

null 46 Dec 19, 2022
A simple to use, composable, command line parser for C++ 11 and beyond

Clara v1.1.5 !! This repository is unmaintained. Go here for a fork that is somewhat maintained. !! A simple to use, composable, command line parser f

Catch Org 648 Dec 27, 2022
A library for interactive command line interfaces in modern C++

cli A cross-platform header only C++14 library for interactive command line interfaces (Cisco style) Features Header only Cross-platform (linux and wi

Daniele Pallastrelli 888 Dec 31, 2022
CLI11 is a command line parser for C++11 and beyond that provides a rich feature set with a simple and intuitive interface.

CLI11: Command line parser for C++11 What's new • Documentation • API Reference CLI11 is a command line parser for C++11 and beyond that provides a ri

null 2.4k Dec 30, 2022
A simple to use, composable, command line parser for C++ 11 and beyond

Lyra A simple to use, composing, header only, command line arguments parser for C++ 11 and beyond. Obtain License Standards Stats Tests License Distri

Build Frameworks Group 388 Dec 22, 2022
A single header C++ library for parsing command line arguments and options with minimal amount of code

Quick Arg Parser Tired of unwieldy tools like getopt or argp? Quick Arg Parser is a single header C++ library for parsing command line arguments

null 47 Dec 21, 2022
CLIp is a clipboard emulator for a command line interface written in 100% standard C only. Pipe to it to copy, pipe from it to paste.

CLIp v2 About CLIp is a powerful yet easy to use and minimal clipboard manager for a command line environment, with no dependencies or bloat. Usage Sy

A.P. Jo. 12 Sep 18, 2021
pbr2gltf2 is a command line tool for converting PBR images to a glTF 2.0 material.

pbr2gltf2 is a command line tool for converting PBR images to a glTF 2.0 material. The tool is detecting depending on the filename, which PBR information is stored. It swizzles the images and does reassign the channels to a glTF 2.0 image. The tool stores the images plus a minimal, valid glTF 2.0 file containing the required material, textures and images.

UX3D GmbH 23 Jul 31, 2022
null 77 Dec 27, 2022
A command-line tool to display colorful distro information.

sjfetch A command-line tool to display colorful distro information.

Fikret Musk 6 Apr 6, 2022