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

Scripts and startup files (no .sh suffix) are not supported. #308

Open
dseynhae opened this issue Dec 21, 2022 · 3 comments
Open

Scripts and startup files (no .sh suffix) are not supported. #308

dseynhae opened this issue Dec 21, 2022 · 3 comments

Comments

@dseynhae
Copy link

I'm using the formatter in VS Code to manage my Bash startup files.
The Bash IDE language server recognizes that they are written in a supported language.

For my scripts, they require a shebang, and the Bash IDE extension kicks in again...

But the vs-shell-format extension seems to insist on the sh suffix to make the formatter available...

Can we provide an option to explicitly list file names where the formatter should be available? The typical startup file names should just be recognized by default...

Or is there another way to force access to this formatter in VS Code?

@dseynhae
Copy link
Author

I'm using a bit of a hack to resolve the situation: I just create a symbolic link to my prefix-less files:

ln -s <file> <file.sh>

Now I can edit the file with the prefix, but the changes (and formatting) happen to my original file:

core -r <file>.sh
...

It's just a bit messy keeping those links around....

@rasa
Copy link
Contributor

rasa commented Jan 12, 2023

Perhaps it could look at shebang line to see if it's a shell script? The shell script formatting command shfmt has a -f option to recursively scan for shell scripts. This command uses the regex:

^#!\s?/(usr/)?bin/(env\s+)?(sh|bash|mksh|bats|zsh)(\s|$)

on the first line of the file here.

@dseynhae
Copy link
Author

A lot of my scripts are sourced (and hence don't have a shebang line).
The shebang line of course is ignored as a comment when sourcing a file, but I don't like to use a shebang line, because it implies that the script can be executed...

Another problem with the shebang, is that the extension now has to consider every file that gets opened, checking for a shebang line...

So as a first compromise, I would like to see support for files like:

.profile
.bash_profile
.bashrc

Or, any file in particular directories:

.bashrc.d
bin

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

No branches or pull requests

3 participants