+/* First element in command line list */
+static struct history *his_front = NULL;
+
+/* Last element in command line list */
+static struct history *his_end = NULL;
+
+
+#include <termios.h>
+#define setTermSettings(fd,argp) tcsetattr(fd,TCSANOW,argp)
+#define getTermSettings(fd,argp) tcgetattr(fd, argp);
+
+/* Current termio and the previous termio before starting sh */
+static struct termios initial_settings, new_settings;
+
+
+static
+volatile int cmdedit_termw = 80; /* actual terminal width */
+static int history_counter = 0; /* Number of commands in history list */
+static
+volatile int handlers_sets = 0; /* Set next bites: */
+
+enum {
+ SET_ATEXIT = 1, /* when atexit() has been called
+ and get euid,uid,gid to fast compare */
+ SET_TERM_HANDLERS = 2, /* set many terminates signal handlers */
+ SET_WCHG_HANDLERS = 4, /* winchg signal handler */
+ SET_RESET_TERM = 8, /* if the terminal needs to be reset upon exit */
+};
+
+
+static int cmdedit_x; /* real x terminal position */
+static int cmdedit_y; /* pseudoreal y terminal position */
+static int cmdedit_prmt_len; /* lenght prompt without colores string */
+
+static int cursor; /* required global for signal handler */
+static int len; /* --- "" - - "" - -"- --""-- --""--- */
+static char *command_ps; /* --- "" - - "" - -"- --""-- --""--- */
+static
+#ifndef BB_FEATURE_SH_FANCY_PROMPT
+ const
+#endif
+char *cmdedit_prompt; /* --- "" - - "" - -"- --""-- --""--- */
+
+/* Link into lash to reset context to 0 on ^C and such */
+extern unsigned int shell_context;
+
+
+#ifdef BB_FEATURE_GETUSERNAME_AND_HOMEDIR
+static char *user_buf = "";
+static char *home_pwd_buf = "";
+static int my_euid;
+#endif
+
+#ifdef BB_FEATURE_SH_FANCY_PROMPT
+static char *hostname_buf = "";
+static int num_ok_lines = 1;
+#endif
+
+
+#ifdef BB_FEATURE_COMMAND_TAB_COMPLETION
+
+#ifndef BB_FEATURE_GETUSERNAME_AND_HOMEDIR
+static int my_euid;
+#endif
+
+static int my_uid;
+static int my_gid;
+
+#endif /* BB_FEATURE_COMMAND_TAB_COMPLETION */
+
+
+static void cmdedit_setwidth(int w, int redraw_flg);
+
+static void win_changed(int nsig)