shell = {}

function shell.get_keywords()
  local keywords0_set = "alias alloc ar asa awk banner basename bash bc bdiff bg bind bindkey break breaksw bs2cmd builtin builtins bunzip2 bye bzip2 cal calendar caller case cat cc cd chdir chgrp chmod chown chroot cksum clear cmp col comm command complete compress continue coproc cp cpio crypt csplit ctags cut date dc dd declare default deroff dev df diff diff3 dir dircmp dircolors dirname dirs disown dnl do done du echo echotc ed egrep elif else enable end endif endsw env esac eval ex exec exit expand export expr factor false fc fg fgrep fi file filetest find fmt fold for foreach function getconf getopt getopts getspath getxvers glob goto grep gres groups hash hashstat head help history hostid hup iconv id if in inlib install integer jobs join kill lc let limit line link ln local log login logname logout look ls m4 mail mailx make man mapfile md5sum migrate mkdir mkfifo mknod more mt mv newgrp nice nl nm no nohup notify ntps od onintr pack paste patch pathchk pax pcat perl pg pinky popd pr print printenv printf ps ptx pushd pwd read readarray readlink readonly red rehash repeat return rev rm rmdir rootnode sched sed select seq set setenv setpath setspath settc setty setxvers sh sha1sum shift shopt shred size sleep sort source spell split start stat stop strings strip stty su sum suspend switch sync tac tail tar tee telltc termname test then time times touch tr trap true tsort tty type typeset ulimit umask unalias uname uncomplete uncompress unexpand unhash uniq universe unlimit unlink unpack unset unsetenv until users uudecode uuencode vdir ver vi vim vpax wait warp watchlog wc whence where which while who whoami wpaste wstart xargs yes zcat"
  local keywords1_set = "do done elif else esac eval fi if then until while"
  local keywords2_set = "AFSUSER BASH BASHOPTS BASHPID BASH_ALIASES BASH_ARGC BASH_ARGV BASH_ARGV0 BASH_CMDS BASH_COMMAND BASH_COMPAT BASH_ENV BASH_EXECUTION_STRING BASH_LINENO BASH_LOADABLES_PATH BASH_REMATCH BASH_SOURCE BASH_SUBSHELL BASH_VERSINFO BASH_VERSION BASH_XTRACEFD CATALINA_BASE CATALINA_HOME CATALINA_OPTS CDPATH CHILD_MAX CLICOLOR_FORCE COLUMNS COMMAND_LINE COMPREPLY COMP_CWORD COMP_KEY COMP_LINE COMP_POINT COMP_TYPE COMP_WORDBREAKS COMP_WORDS COPROC DIRSTACK DISPLAY EDITOR EMACS ENV EPOCHREALTIME EPOCHSECONDS EUID EXECIGNORE FCEDIT FIGNORE FUNCNAME FUNCNEST GLOBIGNORE GROUP GROUPS HISTCMD HISTCONTROL HISTFILE HISTFILESIZE HISTIGNORE HISTSIZE HISTTIMEFORMAT HOME HOST HOSTFILE HOSTNAME HOSTTYPE HPATH IFS IGNOREEOF INPUTRC INSIDE_EMACS JAVA_HOME JAVA_OPTS LANG LC_ALL LC_COLLATE LC_CTYPE LC_MESSAGES LC_NUMERIC LC_TIME LINENO LINES LSCOLORS LS_COLORS MACHTYPE MAIL MAILCHECK MAILPATH MAPFILE NOREBIND OLDPWD OPTARG OPTERR OPTIND OSTYPE PATH PIPESTATUS POSIXLY_CORRECT PPID PROMPT_COMMAND PROMPT_DIRTRIM PS0 PS1 PS2 PS3 PS4 PWD RANDOM READLINE_ARGUMENT READLINE_LINE READLINE_MARK READLINE_POINT REMOTEHOST REPLY SECONDS SHELL SHELLOPTS SHLVL SRANDOM SYSTYPE TERM TERMCAP TIMEFORMAT TMOUT TMPDIR UID USER VENDOR VISUAL"
  return keywords0_set,keywords1_set,keywords2_set
end

function shell.get_autocomplete()
  local autocomplete_set = "alias alloc ar asa awk banner basename bash bc bdiff bg bind bindkey break breaksw bs2cmd builtin builtins bunzip2 bye bzip2 cal calendar caller case cat cc cd chdir chgrp chmod chown chroot cksum clear cmp col comm command complete compress continue coproc cp cpio crypt csplit ctags cut date dc dd declare default deroff dev df diff diff3 dir dircmp dircolors dirname dirs disown dnl do done du echo echotc ed egrep elif else enable end endif endsw env esac eval ex exec exit expand export expr factor false fc fg fgrep fi file filetest find fmt fold for foreach function getconf getopt getopts getspath getxvers glob goto grep gres groups hash hashstat head help history hostid hup iconv id if in inlib install integer jobs join kill lc let limit line link ln local log login logname logout look ls m4 mail mailx make man mapfile md5sum migrate mkdir mkfifo mknod more mt mv newgrp nice nl nm no nohup notify ntps od onintr pack paste patch pathchk pax pcat perl pg pinky popd pr print printenv printf ps ptx pushd pwd read readarray readlink readonly red rehash repeat return rev rm rmdir rootnode sched sed select seq set setenv setpath setspath settc setty setxvers sh sha1sum shift shopt shred size sleep sort source spell split start stat stop strings strip stty su sum suspend switch sync tac tail tar tee telltc termname test then time times touch tr trap true tsort tty type typeset ulimit umask unalias uname uncomplete uncompress unexpand unhash uniq universe unlimit unlink unpack unset unsetenv until users uudecode uuencode vdir ver vi vim vpax wait warp watchlog wc whence where which while who whoami wpaste wstart xargs yes zcat do done elif else esac eval fi if then until while AFSUSER BASH BASHOPTS BASHPID BASH_ALIASES BASH_ARGC BASH_ARGV BASH_ARGV0 BASH_CMDS BASH_COMMAND BASH_COMPAT BASH_ENV BASH_EXECUTION_STRING BASH_LINENO BASH_LOADABLES_PATH BASH_REMATCH BASH_SOURCE BASH_SUBSHELL BASH_VERSINFO BASH_VERSION BASH_XTRACEFD CATALINA_BASE CATALINA_HOME CATALINA_OPTS CDPATH CHILD_MAX CLICOLOR_FORCE COLUMNS COMMAND_LINE COMPREPLY COMP_CWORD COMP_KEY COMP_LINE COMP_POINT COMP_TYPE COMP_WORDBREAKS COMP_WORDS COPROC DIRSTACK DISPLAY EDITOR EMACS ENV EPOCHREALTIME EPOCHSECONDS EUID EXECIGNORE FCEDIT FIGNORE FUNCNAME FUNCNEST GLOBIGNORE GROUP GROUPS HISTCMD HISTCONTROL HISTFILE HISTFILESIZE HISTIGNORE HISTSIZE HISTTIMEFORMAT HOME HOST HOSTFILE HOSTNAME HOSTTYPE HPATH IFS IGNOREEOF INPUTRC INSIDE_EMACS JAVA_HOME JAVA_OPTS LANG LC_ALL LC_COLLATE LC_CTYPE LC_MESSAGES LC_NUMERIC LC_TIME LINENO LINES LSCOLORS LS_COLORS MACHTYPE MAIL MAILCHECK MAILPATH MAPFILE NOREBIND OLDPWD OPTARG OPTERR OPTIND OSTYPE PATH PIPESTATUS POSIXLY_CORRECT PPID PROMPT_COMMAND PROMPT_DIRTRIM PS0 PS1 PS2 PS3 PS4 PWD RANDOM READLINE_ARGUMENT READLINE_LINE READLINE_MARK READLINE_POINT REMOTEHOST REPLY SECONDS SHELL SHELLOPTS SHLVL SRANDOM SYSTYPE TERM TERMCAP TIMEFORMAT TMOUT TMPDIR UID USER VENDOR VISUAL"
  return autocomplete_set
end

function shell.get_reqular()
  local symbol_reqular_exp = "^\\s*(?:function\\s+([_a-zA-Z][_a-zA-Z0-9_]*)|([_a-zA-Z][_a-zA-Z0-9_]*)\\s*\\(\\s*\\))\\s*\\{?"
  return symbol_reqular_exp
end

function shell.create_bakup(path)
  local m_code = {
    "user_shell = {}\n",
    "function user_shell.get_keywords()\n",
    "  local keywords0_set = \"alias alloc ar asa awk banner basename bash bc bdiff bg bind bindkey break breaksw bs2cmd builtin builtins bunzip2 bye bzip2 cal calendar caller case cat cc cd chdir chgrp chmod chown chroot cksum clear cmp col comm command complete compress continue coproc cp cpio crypt csplit ctags cut date dc dd declare default deroff dev df diff diff3 dir dircmp dircolors dirname dirs disown dnl do done du echo echotc ed egrep elif else enable end endif endsw env esac eval ex exec exit expand export expr factor false fc fg fgrep fi file filetest find fmt fold for foreach function getconf getopt getopts getspath getxvers glob goto grep gres groups hash hashstat head help history hostid hup iconv id if in inlib install integer jobs join kill lc let limit line link ln local log login logname logout look ls m4 mail mailx make man mapfile md5sum migrate mkdir mkfifo mknod more mt mv newgrp nice nl nm no nohup notify ntps od onintr pack paste patch pathchk pax pcat perl pg pinky popd pr print printenv printf ps ptx pushd pwd read readarray readlink readonly red rehash repeat return rev rm rmdir rootnode sched sed select seq set setenv setpath setspath settc setty setxvers sh sha1sum shift shopt shred size sleep sort source spell split start stat stop strings strip stty su sum suspend switch sync tac tail tar tee telltc termname test then time times touch tr trap true tsort tty type typeset ulimit umask unalias uname uncomplete uncompress unexpand unhash uniq universe unlimit unlink unpack unset unsetenv until users uudecode uuencode vdir ver vi vim vpax wait warp watchlog wc whence where which while who whoami wpaste wstart xargs yes zcat\"\n",
    "  local keywords1_set = \"do done elif else esac eval fi if then until while\"\n",
    "  local keywords2_set = \"AFSUSER BASH BASHOPTS BASHPID BASH_ALIASES BASH_ARGC BASH_ARGV BASH_ARGV0 BASH_CMDS BASH_COMMAND BASH_COMPAT BASH_ENV BASH_EXECUTION_STRING BASH_LINENO BASH_LOADABLES_PATH BASH_REMATCH BASH_SOURCE BASH_SUBSHELL BASH_VERSINFO BASH_VERSION BASH_XTRACEFD CATALINA_BASE CATALINA_HOME CATALINA_OPTS CDPATH CHILD_MAX CLICOLOR_FORCE COLUMNS COMMAND_LINE COMPREPLY COMP_CWORD COMP_KEY COMP_LINE COMP_POINT COMP_TYPE COMP_WORDBREAKS COMP_WORDS COPROC DIRSTACK DISPLAY EDITOR EMACS ENV EPOCHREALTIME EPOCHSECONDS EUID EXECIGNORE FCEDIT FIGNORE FUNCNAME FUNCNEST GLOBIGNORE GROUP GROUPS HISTCMD HISTCONTROL HISTFILE HISTFILESIZE HISTIGNORE HISTSIZE HISTTIMEFORMAT HOME HOST HOSTFILE HOSTNAME HOSTTYPE HPATH IFS IGNOREEOF INPUTRC INSIDE_EMACS JAVA_HOME JAVA_OPTS LANG LC_ALL LC_COLLATE LC_CTYPE LC_MESSAGES LC_NUMERIC LC_TIME LINENO LINES LSCOLORS LS_COLORS MACHTYPE MAIL MAILCHECK MAILPATH MAPFILE NOREBIND OLDPWD OPTARG OPTERR OPTIND OSTYPE PATH PIPESTATUS POSIXLY_CORRECT PPID PROMPT_COMMAND PROMPT_DIRTRIM PS0 PS1 PS2 PS3 PS4 PWD RANDOM READLINE_ARGUMENT READLINE_LINE READLINE_MARK READLINE_POINT REMOTEHOST REPLY SECONDS SHELL SHELLOPTS SHLVL SRANDOM SYSTYPE TERM TERMCAP TIMEFORMAT TMOUT TMPDIR UID USER VENDOR VISUAL\"\n",
    "  return keywords0_set,keywords1_set,keywords2_set\n",
    "end\n",
    "\n",
    "function user_shell.get_autocomplete()\n",
    "  local autocomplete_set = \"alias alloc ar asa awk banner basename bash bc bdiff bg bind bindkey break breaksw bs2cmd builtin builtins bunzip2 bye bzip2 cal calendar caller case cat cc cd chdir chgrp chmod chown chroot cksum clear cmp col comm command complete compress continue coproc cp cpio crypt csplit ctags cut date dc dd declare default deroff dev df diff diff3 dir dircmp dircolors dirname dirs disown dnl do done du echo echotc ed egrep elif else enable end endif endsw env esac eval ex exec exit expand export expr factor false fc fg fgrep fi file filetest find fmt fold for foreach function getconf getopt getopts getspath getxvers glob goto grep gres groups hash hashstat head help history hostid hup iconv id if in inlib install integer jobs join kill lc let limit line link ln local log login logname logout look ls m4 mail mailx make man mapfile md5sum migrate mkdir mkfifo mknod more mt mv newgrp nice nl nm no nohup notify ntps od onintr pack paste patch pathchk pax pcat perl pg pinky popd pr print printenv printf ps ptx pushd pwd read readarray readlink readonly red rehash repeat return rev rm rmdir rootnode sched sed select seq set setenv setpath setspath settc setty setxvers sh sha1sum shift shopt shred size sleep sort source spell split start stat stop strings strip stty su sum suspend switch sync tac tail tar tee telltc termname test then time times touch tr trap true tsort tty type typeset ulimit umask unalias uname uncomplete uncompress unexpand unhash uniq universe unlimit unlink unpack unset unsetenv until users uudecode uuencode vdir ver vi vim vpax wait warp watchlog wc whence where which while who whoami wpaste wstart xargs yes zcat do done elif else esac eval fi if then until while AFSUSER BASH BASHOPTS BASHPID BASH_ALIASES BASH_ARGC BASH_ARGV BASH_ARGV0 BASH_CMDS BASH_COMMAND BASH_COMPAT BASH_ENV BASH_EXECUTION_STRING BASH_LINENO BASH_LOADABLES_PATH BASH_REMATCH BASH_SOURCE BASH_SUBSHELL BASH_VERSINFO BASH_VERSION BASH_XTRACEFD CATALINA_BASE CATALINA_HOME CATALINA_OPTS CDPATH CHILD_MAX CLICOLOR_FORCE COLUMNS COMMAND_LINE COMPREPLY COMP_CWORD COMP_KEY COMP_LINE COMP_POINT COMP_TYPE COMP_WORDBREAKS COMP_WORDS COPROC DIRSTACK DISPLAY EDITOR EMACS ENV EPOCHREALTIME EPOCHSECONDS EUID EXECIGNORE FCEDIT FIGNORE FUNCNAME FUNCNEST GLOBIGNORE GROUP GROUPS HISTCMD HISTCONTROL HISTFILE HISTFILESIZE HISTIGNORE HISTSIZE HISTTIMEFORMAT HOME HOST HOSTFILE HOSTNAME HOSTTYPE HPATH IFS IGNOREEOF INPUTRC INSIDE_EMACS JAVA_HOME JAVA_OPTS LANG LC_ALL LC_COLLATE LC_CTYPE LC_MESSAGES LC_NUMERIC LC_TIME LINENO LINES LSCOLORS LS_COLORS MACHTYPE MAIL MAILCHECK MAILPATH MAPFILE NOREBIND OLDPWD OPTARG OPTERR OPTIND OSTYPE PATH PIPESTATUS POSIXLY_CORRECT PPID PROMPT_COMMAND PROMPT_DIRTRIM PS0 PS1 PS2 PS3 PS4 PWD RANDOM READLINE_ARGUMENT READLINE_LINE READLINE_MARK READLINE_POINT REMOTEHOST REPLY SECONDS SHELL SHELLOPTS SHLVL SRANDOM SYSTYPE TERM TERMCAP TIMEFORMAT TMOUT TMPDIR UID USER VENDOR VISUAL\"\n",
    "  return autocomplete_set\n",
    "end\n",
    "\n",
    "function user_shell.get_reqular()\n",
    "  local symbol_reqular_exp = \"^\\\\s*(?:function\\\\s+([_a-zA-Z][_a-zA-Z0-9_]*)|([_a-zA-Z][_a-zA-Z0-9_]*)\\\\s*\\\\(\\\\s*\\\\))\\\\s*\\\\{?\"\n",
    "  return symbol_reqular_exp\n",
    "end\n",
    "return user_shell",
  }
  local shell_code = table.concat(m_code)
  eu_core.save_file(path, shell_code)
  shell_code = nil
  m_code = nil
end

return shell