Skip to content

Commit

Permalink
Update shell script command list to Bash 5.2 and tcsh 6.24.
Browse files Browse the repository at this point in the history
  • Loading branch information
zufuliu committed Apr 29, 2023
1 parent c9a368d commit e781ff1
Show file tree
Hide file tree
Showing 6 changed files with 599 additions and 41 deletions.
4 changes: 2 additions & 2 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,8 @@ Latest development builds (artifacts in Release configuration for each compiler
* [Rust](tools/lang/Rust.rs), up to Rust 1.38. [Screenshots](https://github.com/zufuliu/notepad2/wiki/Screenshots#rust)
* [Scala](tools/lang/Scala.scala), up to Scala 3.2.
* Shell Script
* Bash likes (sh, bash, dash, ash, zsh, ksh), [Screenshots](https://github.com/zufuliu/notepad2/wiki/Screenshots#shell-script)
* C Shell (csh, tcsh)
* [Bash](tools/lang/Bash.sh) likes (sh, bash, dash, ash, zsh, ksh), up date to Bash 5.2. [Screenshots](https://github.com/zufuliu/notepad2/wiki/Screenshots#shell-script)
* [C Shell](tools/lang/CShell.csh) (csh, tcsh), up date to tcsh 6.24.
* M4 Macro, limited support
* SQL Query
* [SQL Standard](tools/lang/SQL.sql), up to SQL:2016.
Expand Down
76 changes: 42 additions & 34 deletions src/EditLexers/stlBash.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,47 +2,53 @@
#include "EditStyleX.h"

// https://en.wikipedia.org/wiki/Almquist_shell
// https://en.wikipedia.org/wiki/Bourne_shell
// https://www.gnu.org/software/bash/manual/
// https://en.wikipedia.org/wiki/C_shell
// https://en.wikipedia.org/wiki/KornShell
// https://en.wikipedia.org/wiki/Z_shell

static KEYWORDLIST Keywords_Bash = {{
// built-in
"alias true false yes no if then fi elif else for function functions in return while "
"case esac eval ex exec do done du echo EOF "
// Directory Stack Builtins
"dirs popd pushd "
// C Shell
"end endif foreach switch default breaksw endsw repeat "
// common
"ar asa awk banner basename bash bc bdiff break bunzip2 bzip2 cal calendar cat "
"cc cd chmod cksum clear cmp col comm compress continue cp cpio crypt csplit ctags cut date "
"dc dd declare deroff dev df diff diff3 dircmp dirname ed egrep "
"env exit expand export expr fc fgrep file find fmt fold "
"getconf getopt getopts grep gres hash head help history iconv id integer "
"jobs join kill local lc let line ln logname look ls m4 mail mailx make man mkdir more mt mv "
"newgrp nl nm nohup ntps od pack paste patch pathchk pax pcat perl pg pr print printf ps pwd "
"read readonly red rev rm rmdir sed select set sh shift size sleep sort spell split "
"start stop strings strip stty sum suspend sync tail tar tee test time times touch tr "
"trap tsort tty type typeset ulimit umask unalias uname uncompress unexpand uniq unpack "
"unset until uudecode uuencode vi vim vpax wait wc whence which who wpaste wstart xargs "
"zcat chgrp chown chroot dir dircolors factor groups hostid install link md5sum mkfifo mknod "
"nice pinky printenv ptx readlink seq sha1sum shred stat su tac unlink users vdir whoami yes "
// M4
"dnl "
//++Autogenerated -- start of section automatically generated
"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 "

, // 1 bashStruct
"if elif fi while until else then do done esac eval"
, // 1 bash struct
"do done elif else esac eval fi if then until while "

, // 2 variables
"PATH MANPATH INFOPATH USER TMP TEMP PRINTER HOSTNAME PS1 SHELL "
"JAVA_HOME JAVA_OPTS CATALINA_HOME CATALINA_BASE CATALINA_OPTS "
"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 "

, NULL, NULL, NULL, NULL, NULL, NULL

, NULL, NULL, NULL, NULL, NULL, NULL, NULL
, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL
//--Autogenerated -- end of section automatically generated
}};

static EDITSTYLE Styles_Bash[] = {
Expand Down Expand Up @@ -73,7 +79,9 @@ EDITLEXER lexBash = {
SCE_SH_WORD,
0, 0,
SCE_SH_OPERATOR, 0
, KeywordAttr32(2, KeywordAttr_NoLexer | KeywordAttr_NoAutoComp) // variables
, KeywordAttr32(0, KeywordAttr_PreSorted) // keywords
| KeywordAttr32(1, KeywordAttr_PreSorted | KeywordAttr_NoAutoComp) // bash struct
| KeywordAttr32(2, KeywordAttr_NoLexer) // variables
},
//Settings--Autogenerated -- end of section automatically generated
EDITLEXER_HOLE(L"Shell Script", Styles_Bash),
Expand Down
23 changes: 19 additions & 4 deletions tools/KeywordCore.py
Original file line number Diff line number Diff line change
Expand Up @@ -488,11 +488,26 @@ def parse_awk_api_file(path):
('misc', keywordMap['misc'], KeywordAttr.NoLexer),
]

def parse_bash_api_file(path):
def parse_bash_api_file(pathList):
keywordMap = {
'keywords': [],
'variables': [],
'commands': ['m4', 'dnl'], # M4
}
for path in pathList:
sections = read_api_file(path, '#')
for key, doc in sections:
if key not in keywordMap:
continue
items = doc.split()
if key == 'variables':
items = [item[1:] for item in items]
keywordMap[key].extend(items)
keywordMap['keywords'].extend(keywordMap['commands'])
return [
('keywords', [], KeywordAttr.Default),
('bash struct', [], KeywordAttr.Default),
('variables', [], KeywordAttr.NoLexer | KeywordAttr.NoAutoComp | KeywordAttr.Special),
('keywords', keywordMap['keywords'], KeywordAttr.Default),
('bash struct', "if elif fi while until else then do done esac eval".split(), KeywordAttr.NoAutoComp),
('variables', keywordMap['variables'], KeywordAttr.NoLexer | KeywordAttr.Special),
]

def parse_batch_api_file(path):
Expand Down
2 changes: 1 addition & 1 deletion tools/KeywordUpdate.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
('NP2LEX_AVISYNTH', 'stlAviSynth.c', 'LexAviSynth.cxx', 'AviSynth.avs', 0, parse_avisynth_api_file),
('NP2LEX_AWK', 'stlAwk.c', 'LexAwk.cxx', 'Awk.awk', 1, parse_awk_api_file),

('NP2LEX_BASH', 'stlBash.c', 'LexBash.cxx', '', 0, parse_bash_api_file),
('NP2LEX_BASH', 'stlBash.c', 'LexBash.cxx', ['Bash.sh', 'CShell.csh'], 0, parse_bash_api_file),
('NP2LEX_BATCH', 'stlBatch.c', 'LexBatch.cxx', 'Batch.bat', 0, parse_batch_api_file),

('NP2LEX_CIL', 'stlCIL.c', 'LexCIL.cxx', '', 0, None),
Expand Down
Loading

0 comments on commit e781ff1

Please sign in to comment.