syntax - sh.vim - Unify bashStatement, kshStatement and shStatement#18355
syntax - sh.vim - Unify bashStatement, kshStatement and shStatement#18355bfoersterling wants to merge 2 commits into
Conversation
- unified bashStatement, kshStatement and shStatement as much as possible - separated builtin commands from external programs - cleaned up kornshell flavor logic Signed-off-by: bfoersterling <bjoern.foersterling@gmail.com>
| syn keyword bashSpecialVariables contained auto_resume BASH BASH_ALIASES BASH_ARGC BASH_ARGV BASH_CMDS BASH_COMMAND BASH_ENV BASH_EXECUTION_STRING BASH_LINENO BASHOPTS BASHPID BASH_REMATCH BASH_SOURCE BASH_SUBSHELL BASH_VERSINFO BASH_VERSION BASH_XTRACEFD CDPATH COLUMNS COMP_CWORD COMP_KEY COMP_LINE COMP_POINT COMPREPLY COMP_TYPE COMP_WORDBREAKS COMP_WORDS COPROC COPROC_PID DIRSTACK EMACS ENV EUID FCEDIT FIGNORE FUNCNAME FUNCNEST GLOBIGNORE GROUPS histchars HISTCMD HISTCONTROL HISTFILE HISTFILESIZE HISTIGNORE HISTSIZE HISTTIMEFORMAT HOME HOSTFILE HOSTNAME HOSTTYPE IFS IGNOREEOF INPUTRC LANG LC_ALL LC_COLLATE LC_CTYPE LC_MESSAGES LC_NUMERIC LINENO LINES MACHTYPE MAIL MAILCHECK MAILPATH MAPFILE OLDPWD OPTARG OPTERR OPTIND OSTYPE PATH PIPESTATUS POSIXLY_CORRECT PPID PROMPT_COMMAND PS0 PS1 PS2 PS3 PS4 PWD RANDOM READLINE_LINE READLINE_POINT REPLY SECONDS SHELL SHELLOPTS SHLVL TIMEFORMAT TIMEOUT TMPDIR UID | ||
| syn keyword bashStatement bind builtin caller compgen complete compopt declare dirs disown enable fg help history let logout mapfile popd pushd readarray shopt source suspend time | ||
| syn keyword bashStatement typeset nextgroup=shSetOption | ||
| syn keyword bashAdminStatement daemon reload restart start status stop |
There was a problem hiding this comment.
daemon is of little use, isn't it?
There was a problem hiding this comment.
Right, I have removed it in the latest commit.
reload, restart, start, status, and stop are not that useful either in my opinion, but maybe someone wants these for sys5init scripts.
And I don't think these script have to be in bash, so it should rather be named shAdminStatement and put in global scope.
|
Thanks, I think this makes sense. |
| " =================== | ||
| syn keyword shStatement break cd chdir continue eval exec exit kill newgrp pwd read readonly return shift test trap ulimit umask wait | ||
| " builtins: | ||
| syn keyword shStatement alias bg break cd continue command eval exec exit export fc getopts hash jobs local printf read readonly return shift times trap type ulimit umask unalias wait |
There was a problem hiding this comment.
I haven't tried but this should break the shAlias match as the syn-keyword will have priority.
There was a problem hiding this comment.
Yes, it actually broke it for some reason.
I changed it back and added the test runtime/syntax/testdir/input/sh_bash_alias.sh.
Maybe you can check if it is correct now and if you have an edge case in mind add a test for it.
Thanks for the review.
This is probably |
- fixed alias syntax highlighting - added test for bash alias syntax highlighting - removed daemon keyword Signed-off-by: bfoersterling <bjoern.foersterling@gmail.com>
I don't think this should be highlighted in Bash. For the kornshell: |
|
thanks, let me include it |
- unified bashStatement, kshStatement and shStatement as much as possible - separated builtin commands from external programs - cleaned up kornshell flavor logic - fixed alias syntax highlighting - added test for bash alias syntax highlighting - removed daemon keyword closes: vim/vim#18355 vim/vim@11bde1f Co-authored-by: Bjoern Foersterling <bjoern.foersterling@gmail.com>
- unified bashStatement, kshStatement and shStatement as much as possible - separated builtin commands from external programs - cleaned up kornshell flavor logic - fixed alias syntax highlighting - added test for bash alias syntax highlighting - removed daemon keyword closes: vim/vim#18355 vim/vim@11bde1f Co-authored-by: Bjoern Foersterling <bjoern.foersterling@gmail.com>
…im#35895) - unified bashStatement, kshStatement and shStatement as much as possible - separated builtin commands from external programs - cleaned up kornshell flavor logic - fixed alias syntax highlighting - added test for bash alias syntax highlighting - removed daemon keyword closes: vim/vim#18355 vim/vim@11bde1f Co-authored-by: Bjoern Foersterling <bjoern.foersterling@gmail.com>
Changes
Following the discussion on the mailing list.
I have looked at all keywords and checked if they are built into
bash,dash,ksh, orsh, and if they are external commands.The external programs are still in
shStatementbut they are visuallyseparated by a new vimscript statement in a new line.
Unfortunatelly there are a lot of differences between builtin commands
especially between the different Kornshell flavors and also Dash misses a lot
of builtins.
Maybe the external commands can also be moved to their own syntax group?
But the highlighting will probably stay the same so not sure if this is useful.
Restructured and simplified the logic of the
kornshellflavors.Tried to unify statements whenever possible.
Highlighting for the
rpmcommand was removed as being too distribution specific.Cleanup: formatted with
gg=Gand removed dead code.Rerecorded Tests
testdir/dumps/sh_09_00.dump(letis not a keyword indash)testdir/dumps/sh_ksh2020_05.dump(renameis an ext. command that may be highlighted)testdir/dumps/sh_ksh93u_05.dump(renameis an ext. command that may be highlighted)testdir/dumps/sh_ksh93v_05.dump(renameis an ext. command that may be highlighted)testdir/dumps/sh_ksh88_05.dump(renameis an ext. command that may be highlighted)testdir/dumps/sh_sundrous_03.dump(xgrepshould not be highlighted inbash)renameusually comes preinstalled through https://github.com/util-linux/util-linux/tree/master.xgrepis neither a builtin in bash nor an external command that I could find.