sh
bash-language-server
Our great sponsors
sh | bash-language-server | |
---|---|---|
21 | 23 | |
6,687 | 1,899 | |
- | 3.2% | |
7.8 | 9.4 | |
8 days ago | 2 days ago | |
Go | TypeScript | |
BSD 3-clause "New" or "Revised" License | MIT License |
Stars - the number of stars that a project has on GitHub. Growth - month over month growth in stars.
Activity is a relative number indicating how actively a project is being developed. Recent commits have higher weight than older ones.
For example, an activity of 9.0 indicates that a project is amongst the top 10% of the most actively developed projects that we are tracking.
sh
-
Show HN: Hucksh – A Shell with a Good Memory
* The shell itself is https://github.com/mvdan/sh, a bash-like command interpreter
-
Pure Bash Bible
https://github.com/mvdan/sh
And finally, checkbashisms if you intend on making pure posix scripts that are compatible with debian/ubuntu's dash. It is part of the debian's devscripts suite, but is often individually packaged in other distros.
> Also you can use the chat as a learning tool
Or you could learn from a guide written by people who have suffered decades of experience of the pitfalls of shell scripting and have shared their woes.
-
Shfmt – format shell programs (like gofmt, rustfmt)
For the first two caveats, I actually agree that we could and should handle ambiguous input. It just hasn't been a priority because doing that properly would be quite a bit of work, and such ambiguous syntax isn't particularly common. See https://github.com/mvdan/sh/issues/686 for my current thoughts on how to tackle it.
The third caveat concerns parsing `export` and `let` as keywords rather than as builtins. Like the README says, this is to properly build the syntax without leaving opaque strings as expressions, but also to support `declare foo=(bar)` which wouldn't work if `declare` was treated like any other builtin simple command.
How else would you have a static parser handle these two builtins? They are in a bit of an awkward middle ground between builtin and keyword. My instinct is that giving them special treatment in the parser to allow tokens like `(`, while at the same time representing them in the syntax tree with opaque strings as expressions, would be pretty underwhelming to any users of the parser.
That said, we already have that problem with `let "foo=123"` for example, where our parser currently represents the expression as the quoted string without going any deeper. https://github.com/mvdan/sh/issues/754#issuecomment-96329574... considers doing a second parse stage in the shell interpreter to fix cases like these, though always doing a second parse could get expensive.
We _could_ leave all arithmetic expressions as input strings in the parser, and do all the actual parsing when they are evaluated. That would be more compatible with Bash and more consistent. But it would also be less useful to any parser users who don't run into any of these weird edge cases, which aren't common at all, I think.
In short, I have some ideas, but I'm not sure at all what's best :) Doing a good job for 99% of users feels better than aiming for 100% compatibility with bash syntax, particularly where bash syntax is a bit weird.
-
Gofumpt: It's like gofmt except more strict
My bad, I completely screwed this up... the as of yet undiscussed project is:
(not shmfmt)
-
Gosh Linux shell written in Golang
I support projects like this for purposes of exploration and practice. But don't expect people to use it when there are already well established projects out there like: https://github.com/mvdan/sh
-
similar to shellcheck?
There are also: - shfmt - sh - bash language server - bashate
-
Code formatter, linters, etc. Recommendations?
There is shellcheck, and shellharden which is a strict version of it. There are similar stuff here, some that also help with your editor. You can also use a docker version of shfmt. See here for a quick tutorial on shfmt.
-
First Bash Script
Now go ahead and install shellcheck and shfmt to get even better at it.
-
How can I fix this install script to detect archives, and what are the strange numbers for the permissions? Plz help me understand.
INSTALL_DIR=/usr/local/bin # Call with arguments (location,filename,sha,name,strip) function download_verify_install() { curl -LOf "${1}${2}" echo "${3} ./${2}" | sha512sum --check tar -C $INSTALL_DIR/ -xf "${2}" --no-anchored "${4}" --strip="${5}" } install_redhat_binaries() { BOLD=$(tput bold) RESET=$(tput sgr0) set -euo pipefail local PANDOC_LOCATION=https://github.com/jgm/pandoc/releases/download/2.11.2/ local PANDOC_FILENAME=pandoc-2.11.2-linux-amd64.tar.gz local PANDOC_SHA=9d265941f224d376514e18fc45d5292e9c2481b04693c96917a0d55ed817b190cf2ea2666097388bfdf30023db2628567ea04ff6b9cc3316130a8190da72c605 local SHELLCHECK_LOCATION=https://github.com/koalaman/shellcheck/releases/download/v0.7.2/ local SHELLCHECK_FILENAME=shellcheck-v0.7.2.linux.x86_64.tar.xz local SHELLCHECK_SHA=067e2b8ee1910218de1e62068f7cc86ed7048e97b2a9d7c475ea29ae81c17a944376ce5c240d5c783ef3251d9bee7d7d010351958314eadd0fc88b5decfd8328 local SHFMT_LOCATION=https://github.com/mvdan/sh/releases/download/v3.2.2/ local SHFMT_FILENAME=shfmt_v3.2.2_linux_amd64 local SHFMT_SHA=d4e699575899f7c44dbce54f6414fb63c0527e7d743ea724cb0091417e07a353c1d156d4184580a260ca855cdf5e01cdf46b353f04cf5093eba3ffc02223f1c6 local BAT_LOCATION=https://github.com/sharkdp/bat/releases/download/v0.18.1/ local BAT_FILENAME=bat-v0.18.1-x86_64-unknown-linux-gnu.tar.gz local BAT_SHA=5ccab17461d2c707dab2e917daacdabe744c8f8c1e09330c03f17b6f9a9be3d79d8a2786c5e37b1bdbdb981e9d9debfec909b4a99bf62329d6f12c1c3e8dfcb7 local RIPGREP_LOCATION=https://github.com/BurntSushi/ripgrep/releases/download/13.0.0/ local RIPGREP_FILENAME=ripgrep-13.0.0-x86_64-unknown-linux-musl.tar.gz local RIPGREP_SHA=cdc18bd31019fc7b8509224c2f52b230be33dee36deea2e4db1ee8c78ace406c7cd182814d056f4ce65ee533290a674822432777b61c2b4bc8cc4a4ea107cfde echo -e "${BOLD}Installing binaries for RHEL clones not available in repositories...${RESET}\n" download_verify_install "$PANDOC_LOCATION" "$PANDOC_FILENAME" "$PANDOC_SHA" "pandoc" 2 download_verify_install "$SHELLCHECK_LOCATION" "$SHELLCHECK_FILENAME" "$SHELLCHECK_SHA" "shellcheck" 1 download_verify_install "$BAT_LOCATION" "$BAT_FILENAME" "$BAT_SHA" "bat" 1 download_verify_install "$RIPGREP_LOCATION" "$RIPGREP_FILENAME" "$RIPGREP_SHA" "rg" 1 # download_verify "$SHFMT_LOCATION" "$SHFMT_FILENAME" "$SHFMT_SHA" # chmod +x $SHFMT_FILENAME # mv $SHFMT_FILENAME $INSTALL_DIR/shfmt } install_redhat_binaries
bash-language-server
-
Being a bash developer in the 21st century
In neovim I would recommend setting shellcheck with null.ls or using the bash language server: https://github.com/bash-lsp/bash-language-server
both work really well
- Oils 0.17.0 – YSH Is Becoming Real
-
The Case for Bash (2021)
Also maybe check out the bash language server.
-
Eglot or LSP complete in shell?
In that case, I think Eglot supports this language server: https://github.com/bash-lsp/bash-language-server out of the box but I've never tried it.
- How often do you google or search for Bash commands/syntax?
-
similar to shellcheck?
There are also: - shfmt - sh - bash language server - bashate
-
How to improve your vim/nvim coding experience with vim-easycomplete?
Shell: bash-language-server required.
-
Ask HN: Let's Build CheckStyle for Bash?
- Bash Language Server: https://github.com/bash-lsp/bash-language-server
-
Common shell script mistakes (2008)
As well, having a bash language server enabled (https://github.com/bash-lsp/bash-language-server) helps immensely.
-
How can I debug why an LSP is crashing?
I have a very similar issue with bash-ls.
What are some alternatives?
ShellCheck - ShellCheck, a static analysis tool for shell scripts
nvim-lspconfig - Quickstart configs for Nvim LSP
bat - A cat(1) clone with wings.
go-pkg-xmlx
LSP-bash - Bash support for Sublime's LSP plugin provided through bash-language-server.
go-pkg-rss
inject
toml - TOML parser for Golang with reflection.
blackfriday - Blackfriday: a markdown processor for Go
bluemonday - bluemonday: a fast golang HTML sanitizer (inspired by the OWASP Java HTML Sanitizer) to scrub user generated content of XSS
syntastic - Syntax checking hacks for vim