Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bash mode #37

Open
11 of 25 tasks
parro-it opened this issue Sep 21, 2016 · 6 comments
Open
11 of 25 tasks

Bash mode #37

parro-it opened this issue Sep 21, 2016 · 6 comments
Assignees

Comments

@parro-it
Copy link
Collaborator

parro-it commented Sep 21, 2016

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
@parro-it
Copy link
Collaborator Author

parro-it commented Oct 12, 2016

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)

Also, see http://stackoverflow.com/questions/28114999/what-are-the-rules-for-valid-identifiers-e-g-functions-vars-etc-in-bash

@nfischer
Copy link
Collaborator

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!

@wsxiaoys
Copy link

wsxiaoys commented Jun 15, 2017

pseudo file, like <(echo 123) is also not supported yet?

@parro-it
Copy link
Collaborator Author

pseudo file, like <(echo 123) is also not supported yet?

Not yet, but it is in the list, is called process substitution.

@piranna
Copy link
Collaborator

piranna commented Aug 15, 2017

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?

@piranna
Copy link
Collaborator

piranna commented Aug 21, 2020

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 :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants