-
Notifications
You must be signed in to change notification settings - Fork 73
[Suggestion] autodetect files as bash based on the shebang #213
Comments
Do you have .sh files which are not Bash and would like BashSupport to not parse them? BashSupport can detect files based on the shebang if there is no file extension. If you want to treat *.sh as Bash: this should be the default.
|
no. I have files without extensions which should be treated as Bash. They have the the plugin does not seem to detect them as bash |
hmm, looking at the code, it seems that the detection based on the content does not support the shebangs using |
+1 to get this please, running into this in PyCharm, specifically |
@jansorg I'm sorry to neglect to mention. Without extension. |
@j-funk @stof "/sbin/bash", The "Add new Bash file" action currently always adds a fallback extension (.sh). I could add an option to disable this fallback if you prefer to add files without extensions. Is that a fix for your guys or do you need something else? |
@jansorg not sure what you mean, my usecase is the following:
At the moment, there is no styling on the text so I suppose that BashSupport is not detecting. If I modify a file to add the |
@j-funk Which version of BashSupport do you use? |
@jansorg 1.5.2.141 |
@j-funk |
Hey @jansorg I'm afraid it's not public. Worth noting that it does not reproduce when I try running |
I was facing that issue, too. Here is a workaround for files that have #!/usr/bin/env bash that don't get recognized:
It seems to work for me. |
might be related to #262 |
Let me resurrect this issue |
@fabiocarneiro this has nothing to do with this issue. This is the issue tracker of the BashSupport plugin, so its own autodetection is about detecting Bash files. This plugin is not about detecting language for other kind of files based on the shebang (this is a nice idea for a plugin, but definitely a different one) |
@stof As far as I could understand the program loader(which is bash) calls PHP to execute this script. Doesn't it make sense then, that any file without extension and/or with shebang should then be detected as a bash script by BashSupport plugin? And consequently formatted with the interpreter program language, which for me is PHP? |
@fabiocarneiro You're right that the shell (in your case Bash) looks at the shebang line and then calls that executable with the rest of the script file (in your case php). There are other shells which also support shebang lines (afaik). BashSupport supports Bash/Sh syntax only. It only has handlers to detect whether a file without an extension is probably a bash file. PHPStorm should detect your file as php. I'm not sure whether it has a feature to do this. If it doesn't I'd suggest to open a ticket in the JetBrains Youtrack issue tracker. BashSupport can't/won't handle any other language than Bash because it would need dependencies to all kinds of other language plugins to handle all possible cases (PHP, Javascript/node, Python, Perl, ...). |
After update to pycharm 2017.1 BashSupport no longer detects simple |
After update to pycharm 2017.1 BashSupport sometimes fails to detects simple #!/bin/bash as bash file, for other files it works, really strange, I can't see a pattern when it works and when not |
This isn't working on IDEA Ultimate 2019.1.3. It's failing to detect extension-less files with shebang: |
It is very common to have shell scripts with the
.sh
extension. In such case, PhpStorm currently requires us to register each file individually as being treated as bash, which is painful. It would be great if the plugin could autodetect the format based on the shebang to highlight files as bash when the shebang is here.I'm not sure PhpStorm allows to do that though.
The text was updated successfully, but these errors were encountered: