bash-explainer 0.1.1 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +62 -5
- package/THIRD_PARTY_NOTICES.md +7 -7
- package/dist/cli.js +121 -108
- package/dist/tree-sitter-bash.wasm +0 -0
- package/dist/web-tree-sitter.wasm +0 -0
- package/package.json +1 -1
- package/dist/tree-sitter.wasm +0 -0
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# bash-explainer
|
|
2
2
|
|
|
3
|
-
Explains shell scripts line by line in the terminal — every command, option, redirection and `${…}` — with worked examples. The command-line companion of the [Bash Explainer](https://marketplace.visualstudio.com/items?itemName=shun-fujioka.bash-explainer) VS Code extension, with the same explanations.
|
|
3
|
+
Explains shell scripts line by line in the terminal — every command, option, redirection and `${…}` — with worked examples, and points out common pitfalls (unquoted variables, `x = 1`, `for f in $(ls)`…). The command-line companion of the [Bash Explainer](https://marketplace.visualstudio.com/items?itemName=shun-fujioka.bash-explainer) VS Code extension, with the same explanations.
|
|
4
4
|
|
|
5
5
|
**Offline by design:** no network, no AI, no telemetry. English and Japanese.
|
|
6
6
|
|
|
@@ -34,7 +34,7 @@ bash-explainer deploy.sh:12 # one line (or deploy.sh:12-20)
|
|
|
34
34
|
bash-explainer -e 'cmd 2>&1 > out' # a command line
|
|
35
35
|
cat deploy.sh | bash-explainer - # standard input
|
|
36
36
|
bash-explainer Dockerfile # the shell code in Dockerfiles, Makefiles, CI YAML,
|
|
37
|
-
# package.json, Markdown and Python
|
|
37
|
+
# Jenkinsfiles, package.json, Markdown and Python
|
|
38
38
|
bash-explainer --check install.sh # constructs its shell (#!/bin/sh: dash…) lacks
|
|
39
39
|
```
|
|
40
40
|
|
|
@@ -44,13 +44,70 @@ bash-explainer --check install.sh # constructs its shell (#!/bin/sh: dash…
|
|
|
44
44
|
| `-l`, `--line <n>[-<m>]` | only these lines |
|
|
45
45
|
| `--check` | report constructs the script's shell lacks, and other risks (script injection in GitHub Actions, Docker `RUN` pipes without `pipefail`…); exit 1 if there is a warning |
|
|
46
46
|
| `--shell <name>` | the script's shell: `bash`, `sh`, `dash`, `ash`, `yash`, `ksh`, `mksh`, `zsh` (default: from the shebang or the file name) |
|
|
47
|
-
| `--kind <kind>` | what the file is: `shell`, `dockerfile`, `makefile`, `yaml`, `npm`, `markdown`, `python` (default: from the file name) |
|
|
47
|
+
| `--kind <kind>` | what the file is: `shell`, `dockerfile`, `makefile`, `yaml`, `npm`, `markdown`, `python`, `jenkinsfile` (default: from the file name) |
|
|
48
48
|
| `--lang <en\|ja>` | language (default: from `LANG`) |
|
|
49
|
-
| `--format <format>` | `text`, `markdown` or `json` |
|
|
49
|
+
| `--format <format>` | `text`, `markdown` or `json`; with `--check`, also `github` (annotations in GitHub Actions) or `sarif` (for code scanning) |
|
|
50
50
|
| `--no-examples` | leave out worked examples |
|
|
51
|
+
| `--lsp` | run as a Language Server on standard input and output (see [In your editor](#in-your-editor-language-server)) |
|
|
51
52
|
| `--color`, `--no-color` | colour the text output (default: when writing to a terminal; `NO_COLOR` turns it off) |
|
|
52
53
|
|
|
53
|
-
`--check` prints problems as compilers do (`file:line:column: warning: … [code]`), so editors and CI can pick them up.
|
|
54
|
+
`--check` prints problems as compilers do (`file:line:column: warning: … [code]`), so editors and CI can pick them up. With `--format github` they become GitHub Actions annotations, shown on the pull request's diff; with `--format sarif`, a SARIF file for code scanning.
|
|
55
|
+
|
|
56
|
+
## In CI (GitHub Actions)
|
|
57
|
+
|
|
58
|
+
The repository is also a GitHub Action, which runs this tool at its own version:
|
|
59
|
+
|
|
60
|
+
```yaml
|
|
61
|
+
- uses: actions/checkout@v5
|
|
62
|
+
- uses: sf624/bash-explainer@v0
|
|
63
|
+
with:
|
|
64
|
+
files: '**/*.sh Dockerfile .github/workflows/*.yml'
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
`@v0` follows the latest 0.x release. To stay on one version, use its tag (`@v0.2.0`); to be sure the code cannot change, its commit SHA (`@<sha> # v0.2.0`), which Dependabot can keep up to date.
|
|
68
|
+
|
|
69
|
+

|
|
70
|
+
|
|
71
|
+
Warnings appear on the pull request's diff, and fail the step (`fail-on-warning: 'false'` keeps it green). The inputs: `files` (bash globs; default `**/*.sh`), `shell` (default: from each script), `fail-on-warning`, `sarif` (also write a SARIF file, for `github/codeql-action/upload-sarif`) and `package` (another npm package spec to run). The output `warnings` is the number of warnings. In other CI systems, run `npx bash-explainer --check <files>` and use the exit status.
|
|
72
|
+
|
|
73
|
+
## In your editor (Language Server)
|
|
74
|
+
|
|
75
|
+
`bash-explainer --lsp` is a Language Server on standard input and output: hover a line for its explanation, and get the warnings with their quick fixes, in any editor that speaks LSP. It handles shell scripts (language IDs `sh`, `bash`, `zsh`, `shellscript`…) and the shell code in Dockerfiles, Makefiles, YAML, `package.json`, Markdown, Python and Jenkinsfiles. It runs next to other servers, such as bash-language-server.
|
|
76
|
+
|
|
77
|
+
Install it with `npm install --global bash-explainer` (see [Installation](#installation)), so the editor does not wait for `npx`.
|
|
78
|
+
|
|
79
|
+
**Neovim** (0.11 or later), in `init.lua`:
|
|
80
|
+
|
|
81
|
+
```lua
|
|
82
|
+
vim.lsp.config('bash_explainer', {
|
|
83
|
+
cmd = { 'bash-explainer', '--lsp' },
|
|
84
|
+
filetypes = { 'sh', 'bash', 'zsh', 'dockerfile', 'make', 'yaml', 'groovy' },
|
|
85
|
+
root_markers = { '.git' },
|
|
86
|
+
-- init_options = { language = 'ja', shell = 'dash' },
|
|
87
|
+
})
|
|
88
|
+
vim.lsp.enable('bash_explainer')
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
**Helix**, in `languages.toml`:
|
|
92
|
+
|
|
93
|
+
```toml
|
|
94
|
+
[language-server.bash-explainer]
|
|
95
|
+
command = "bash-explainer"
|
|
96
|
+
args = ["--lsp"]
|
|
97
|
+
|
|
98
|
+
[[language]]
|
|
99
|
+
name = "bash"
|
|
100
|
+
language-servers = ["bash-language-server", "bash-explainer"]
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
**Emacs** (Eglot, one server per mode):
|
|
104
|
+
|
|
105
|
+
```elisp
|
|
106
|
+
(with-eval-after-load 'eglot
|
|
107
|
+
(add-to-list 'eglot-server-programs '((sh-mode bash-ts-mode) . ("bash-explainer" "--lsp"))))
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
Settings, as `initializationOptions` or through `workspace/didChangeConfiguration` (under `bashExplainer`): `language` (`en` or `ja`; default from `LANG`), `shell` (the shell to check for; default: from the file), `examples` (`false` leaves out worked examples).
|
|
54
111
|
|
|
55
112
|
## Privacy
|
|
56
113
|
|
package/THIRD_PARTY_NOTICES.md
CHANGED
|
@@ -8,8 +8,8 @@ Bash Explainer includes the following third-party software (MIT). Their license
|
|
|
8
8
|
|
|
9
9
|
| Component | Version | License | Included as |
|
|
10
10
|
| --- | --- | --- | --- |
|
|
11
|
-
| [tree-sitter-bash](https://github.com/tree-sitter/tree-sitter-bash) | 0.
|
|
12
|
-
| [web-tree-sitter](https://github.com/tree-sitter/tree-sitter
|
|
11
|
+
| [tree-sitter-bash](https://github.com/tree-sitter/tree-sitter-bash) | 0.25.1 | MIT | `dist/tree-sitter-bash.wasm` |
|
|
12
|
+
| [web-tree-sitter](https://github.com/tree-sitter/tree-sitter) | 0.27.0 | MIT | bundled into `dist/extension.js`; bundled into `dist/web/extension.js`; `dist/web-tree-sitter.wasm` |
|
|
13
13
|
|
|
14
14
|
## In the web version
|
|
15
15
|
|
|
@@ -26,16 +26,16 @@ Bash Explainer includes the following third-party software (MIT). Their license
|
|
|
26
26
|
| [@marijn/find-cluster-break](https://code.haverbeke.berlin/marijn/find-cluster-break) | 1.0.4 | MIT | bundled into `app.js` |
|
|
27
27
|
| [crelt](https://code.haverbeke.berlin/marijn/crelt) | 1.0.7 | MIT | bundled into `app.js` |
|
|
28
28
|
| [style-mod](https://code.haverbeke.berlin/marijn/style-mod) | 4.1.4 | MIT | bundled into `app.js` |
|
|
29
|
-
| [tree-sitter-bash](https://github.com/tree-sitter/tree-sitter-bash) | 0.
|
|
29
|
+
| [tree-sitter-bash](https://github.com/tree-sitter/tree-sitter-bash) | 0.25.1 | MIT | `tree-sitter-bash.wasm` |
|
|
30
30
|
| [w3c-keyname](https://github.com/marijnh/w3c-keyname#readme) | 2.2.8 | MIT | bundled into `app.js` |
|
|
31
|
-
| [web-tree-sitter](https://github.com/tree-sitter/tree-sitter
|
|
31
|
+
| [web-tree-sitter](https://github.com/tree-sitter/tree-sitter) | 0.27.0 | MIT | bundled into `app.js`; `web-tree-sitter.wasm` |
|
|
32
32
|
|
|
33
33
|
## In the command-line tool (npm package bash-explainer)
|
|
34
34
|
|
|
35
35
|
| Component | Version | License | Included as |
|
|
36
36
|
| --- | --- | --- | --- |
|
|
37
|
-
| [tree-sitter-bash](https://github.com/tree-sitter/tree-sitter-bash) | 0.
|
|
38
|
-
| [web-tree-sitter](https://github.com/tree-sitter/tree-sitter
|
|
37
|
+
| [tree-sitter-bash](https://github.com/tree-sitter/tree-sitter-bash) | 0.25.1 | MIT | `dist/tree-sitter-bash.wasm` |
|
|
38
|
+
| [web-tree-sitter](https://github.com/tree-sitter/tree-sitter) | 0.27.0 | MIT | bundled into `dist/cli.js`; `dist/web-tree-sitter.wasm` |
|
|
39
39
|
|
|
40
40
|
## License texts
|
|
41
41
|
|
|
@@ -220,7 +220,7 @@ THE SOFTWARE.
|
|
|
220
220
|
```text
|
|
221
221
|
The MIT License (MIT)
|
|
222
222
|
|
|
223
|
-
Copyright (c) 2018
|
|
223
|
+
Copyright (c) 2018 Max Brunsfeld
|
|
224
224
|
|
|
225
225
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
226
226
|
of this software and associated documentation files (the "Software"), to deal
|