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

cmd/shfmt: document when --filename is needed for EditorConfig support #1058

Merged
merged 1 commit into from
Feb 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions cmd/shfmt/shfmt.1.scd
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ predictable. Some aspects of the format can be configured via printer flags.

## Generic flags

*-version*
*--version*
Show version and exit.

*-l*, *--list*
Expand Down Expand Up @@ -70,9 +70,12 @@ predictable. Some aspects of the format can be configured via printer flags.
*-p*, *--posix*
Shorthand for *-ln=posix*.

*-filename* str
*--filename* str
Provide a name for the standard input file.

Use of this flag is necessary for EditorConfig support to work with stdin,
since EditorConfig files are found relative to the location of a script.

## Printer flags

*-i*, *--indent* <uint>
Expand Down
4 changes: 4 additions & 0 deletions cmd/shfmt/testdata/script/editorconfig.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ stdin stdin-filename-bash
! exec shfmt -filename=foo_posix.sh
stderr '^foo_posix.sh:.* arrays are a bash'

stdin stdin-filename-bash
! exec shfmt -filename=${WORK}/foo_posix.sh
stderr ^${WORK@R}/'foo_posix.sh:.* arrays are a bash'

# Using a file path should use EditorConfig, including with the use of flags
# like -l.
exec shfmt input.sh
Expand Down