A question before buying

Hi,

I am using Intellij, and I was searching something better than the “default” shell plugin from Intellij “Shell Script”.

I am a heavy user of KSH shell script, and due to historical reason, I cannot change the scripts from KSH to BASH.
So now I must live with what I have.

My problem is the following, when I use “Shell Script” that use the shfmt module… the shfmt module has really some strong idea on how the source code must look like.
For example in ksh the functions

function name {…} are NEVER written like function name() {…}.
This is an error of syntax. It might work with bash or sh, but not ksh.
I have also read the documentation of bash, and depending on which needs one has, the function can be defined with or without the () at the end of the function name. The same with the term “function” it can be used or not, depending on what you want to achieve.

That said… I wanted to know if BashSupport Pro does change the source code during a reformatting like “Shell Script”, and if yes, is it possible to disable such unwanted reformatting of the code.
And I know that the name “BashSupport Pro” is mainly for Bash… but is there any support for other shell, like KSH?

Thank you for your help to understand if I need or not to buy this plugin for my needs.

Kind regards,
Alessandro

I have use the trial, so I can test it…
And I can see the same “bug” is happening with “BashSupport Pro” like the “Shell Script”, the reformatting of the code is wrong for KSH, the function are renamed with a () at the end of the function name.
I suppose this is a bug from the shfmt program… or at least, I consider it as a bug.
I suppose, also that there is nothing that you can do to solve that problem… and if I need some support I need either to ask my question to the shfmt team, or write my own shfmt tool!

Or do I see the things wrongly?

Hi @PtitVert, thanks for your question and feedback – that’s very helpful.

In general, BashSupport Pro is parsing POSIX and Bash at this time. I’m thinking about support for more dialects like ksh, zsh, and fish. But I haven’t decided about this, yet.

Regarding the reformatting error:
Bash support a() {...} as in POSIX, and also function a() {...} and function a {...}. ksh only seems to support the latter.
I checked shfmt, it’s always adding () parentheses if it’s function a .... I just submitted a patch to change this and to keep the original format, if possible.

You have to choices here:

  • Write your functions as a() {...}.
  • or wait for the next update, which will bundle shfmt with my patch above. Unless things go wrong this update should be out later today.

Please note that BashSupport Pro isn’t fully supporting ksh yet. There may be further incompatibilities like this one. In this case, let me know about this and I’ll see what I can do. But full support for the language, as for Bash, will take a while.

Regards,
Joachim

Hi @PtitVert, the stable version with the fix for the formatter takes some more time.
There’s an eap version at https://plugins.jetbrains.com/plugin/13841-bashsupport-pro/versions/eap, if you’d like to try if it’s what you need. The stable update should be out next week.

Regards,
Joachim

Hi Jason,

Wow :slight_smile: that’s great!! :slight_smile: thank you!

Well concerning your 2 suggestions:

  1. I won’t change from “function a” to “a()” because in KSH when you do that, you loose the capability of having local variable. Every variable created in a() with typeset are still seen as global, and with function a, they are seen as local variables… strange but that what I’ve experienced.
  2. For the moment, I keep the automatic formatter of Intellij disabled, so I can enjoy the coloring and advices! :smiley: In fact the only problem I have is when I want to reformat, then it becomes in my case a mess (at least with the function a() change).

I understand, normally ksh is quite near to bash, in fact nearly all the scripts in ksh I work with, works with nearly zero changes in bash.
Well I need to dig into the differences betweeen a(), function a and function a() in bash to see what are the differences between the 3 variants.

Regards,
Alessandro

I will try the new version on Monday :smiley: thanks!

Veresion 1.5.8 has been released to all users today and contains the change for the fixed ksh formatting.