dense-analysis / dense-analysis/ale
[sh] formatting with shfmt behaves differently if it knows the filename. Use -filename <x> option
- Dominant language
- Vim Script
- Stars
- 14k
- Forks
- 1.5k
- Avg merge
- 17h 49m
- Merged PRs (30d)
- 1
Description
Latest VIM (master)
Latest ALE (master)
It appears the `shfmt` shell formatter behaves differently when it knows the filename of the file it is formatting.
For example;
With ale_fix_on_save enabled for shell scripts (filetype=sh), ALE Info shows the following command;
```
(finished - exit code 0) ['/bin/bash', '-c', '''shfmt'' < ''/tmp/vaFRodP/12/open.sh''']
```
When formatting manually via
```
shfmt -d .
```
The `shfmt` command shows a range of differences.
However, when providing the correct filename information to `shfmt` by setting `b:ale_sh_shfmt_options` to include the filename via
```
let b:ale_sh_shfmt_options = '-filename '.expand('%')
```
The result is ale runs
```
(finished - exit code 0) ['/bin/bash', '-c', '''shfmt'' -filename scripts/open.sh < ''/tmp/vrnwCic/12/open.sh''']
```
and using
```
shfmt -d .
```
no longer shows any differences.
Could we please update the `shfmt` handler functions to _always_ add the option `-filename ` to all invocations of `shfmt` (where the buffer has a filename of course.)
Contributor guide
Assessment
This issue has not been assessed yet.