Bash mode
Opened this issue · 6 comments
This is a list of features to implement in the bash
mode. See https://www.gnu.org/software/bash/manual/html_node/Major-Differences-From-The-Bourne-Shell.html#Major-Differences-From-The-Bourne-Shell
- alias expansion should be applied to reserved word
- tilde expansion should occur on all assignments, even in suffixes
- function names could contains characters different than POSIX
- function could be defined using the function keyword
- single quotes inside parameter expansion could be used to quote characters
- implement process substitution syntax
- expansion of special parameter
$_
- Brace Expansion {a b c}
- Parameter Substring Expansion ${parameter:offset:length}
- Parameter Variable name prefix Expansion
${!prefix}
and${!prefix@}
- Parameter Array Expansion
${!name[@]}
and${!name[]}
- Parameter Character length Expansion
${#parameter}
- Parameter filename expansion
${parameter#word}
and${parameter##word
- Parameter filename delete expansion
${parameter%word}
and${parameter%%word}
- Parameter string replacement
${parameter/pattern/string}
and${parameter//pattern/string}
- Parameter case modification
${parameter^pattern}
,${parameter^^pattern}
,${parameter,pattern}
,${parameter,,pattern}
- Parameter escaping expansion
${parameter@operator}
- Arithmetic form of for statement:
for (( expr1 ; expr2 ; expr3 )) ; do commands ; done
- select statement
- Process Substitution
- Array variables
-
+=
assignment operator - indirect variable expansion
${!word}
-
<>
redirection operator -
<<<
redirection operator
Regarding function name,
- If the
function
reserved word is supplied, the parentheses are optional - name may be the same as one of the special builtins or as one of the reserved words (POSIX forbids that)
name may be the same as one of the special builtins or as one of the reserved words (POSIX forbids that)
Interesting, that's good to know!
pseudo file, like <(echo 123)
is also not supported yet?
pseudo file, like <(echo 123) is also not supported yet?
Not yet, but it is in the list, is called process substitution.
Does we have a similar list for the posix
mode? Or could be consider posix
mode complete? How can we select one mode or the other?
At https://htmlpreview.github.io/?https://raw.githubusercontent.com/michaelmacinnis/oh/master/doc/comparison.html there's a comparasion of features and syntax of several shells, in particular bash
, fish
, oh
, tcsh
and zsh
, and at https://hyperpolyglot.org/unix-shells there's also tips about ksh
. It's a shame there's no info for POSIX sh
, but probably could be useful to add support for additional modes. I was thinking features can be implemented like plugins or rules, with an unified API and later enabling them, similar to how eslint
rules works, that would allow to add additional custom syntax or create a parser that can identify several (or all) of them at the same time, for example checking for the different enabled syntax for a particular rule and identify who was the winner :-)