Shellcheck Tool and Shell Command Checkbox

Plugins for SynWrite and CudaText...
Post Reply
Random Void User
Posts: 84
Joined: 13.07.2024 21:19

Shellcheck Tool and Shell Command Checkbox

Post by Random Void User »

It should be simple to define a CudaText "tool" for the external shellcheck utility. I tried, but did not succeed. How might this tool be configured?

In general, my tools all invoke bash explicitly. I put commands in the parameter field with the -c switch for bash. I have never been able to check "Shell command" and have any tool work that way. What is the nature of this option? When should it be used? Thanks.
main Alexey
Posts: 2863
Joined: 25.08.2021 18:15

Re: Shellcheck Tool and Shell Command Checkbox

Post by main Alexey »

ShellCheck integration was added n weeks ago - this plugin in the addons-manager:
linter: Bash_using_ShellCheck

readme file:
https://github.com/CudaText-addons/cuda ... /README.md

it is subplugin for the CudaLint, so CudaLint is required.
main Alexey
Posts: 2863
Joined: 25.08.2021 18:15

Re: Shellcheck Tool and Shell Command Checkbox

Post by main Alexey »

About 'Shell command' checkbox in the ExternalTools plugin. it activates this param of subprocess.Popen: "shell".

AI writes this:
https://grok.com/share/c2hhcmQtMi1jb3B5 ... 71afcb01e2
Random Void User
Posts: 84
Joined: 13.07.2024 21:19

Re: Shellcheck Tool and Shell Command Checkbox

Post by Random Void User »

I read the Grok output, thank you. I also know about the plug-in. I have been experimenting with "tools" instead.

The shellcheck plug-in uses Python, but I was looking for straight execution. Apparently "tools" route their OS calls through Python. I thought they were going through straight compiled Pascal code to the OS, just as compiled C code would work.

My tools all use shell=false, but effectively do the same thing as shell=true. They call /usr/bin/bash as command, and "-c ....whatever..." as parameter. I have never seen any of my tools work correctly when shell=true.

I probably do not understand the intent behind tools or the mechanisms involved. I'm glad to have the shellcheck plug-in, but just wanted to try it as a tool, which I guessed should be simpler than the plug-in Python code. After all, it's just an OS call against the open file window. So my learning could apply to any number of other OS calls.

For example, I just made a "tool" that strips blank lines from the current selection. It leaves the shell checkbox unchecked, but invokes /usr/bin/bash explicitly with this param string:

Code: Select all

-c '/usr/bin/strings --all --unicode=default --encoding=S --bytes=1 <(echo -n -E "{SelectedText}")'
and "Replace selection" as the tool output choice.

Is there a way to rewrite this blank line removal tool with the checkbox checked? Which way is more correct for this tool, or shellcheck, or any other text utility? According to Grok, redirection usage means it should have the shell box checked. How would you rewrite it? Or would you? Thanks.
main Alexey
Posts: 2863
Joined: 25.08.2021 18:15

Re: Shellcheck Tool and Shell Command Checkbox

Post by main Alexey »

> a way to rewrite this blank line removal tool with the checkbox checked?

that is the question for all users, not exactly for me. I only can guess something.
{SelectionAsTemp} - Name of [temporary] file with selected text
do you know this ExtTools macro? can you use it to replace bash-input-redirection?
Random Void User
Posts: 84
Joined: 13.07.2024 21:19

Re: Shellcheck Tool and Shell Command Checkbox

Post by Random Void User »

I just cloned my working "strings" tool and modified the clone: checked "Shell command" and changed command item to /usr/bin/strings with this param string:

Code: Select all

--all --unicode=default --encoding=S --bytes=1 "{SelectionAsTemp}"
This experiment did not work, but did not emit errors.
main Alexey
Posts: 2863
Joined: 25.08.2021 18:15

Re: Shellcheck Tool and Shell Command Checkbox

Post by main Alexey »

yes, for me this tool, with 'Shell' checked, gives empty output. if I clear 'Shell' checkbox, it removes empty lines OK.
I don't know why. this is interesting.
bug in the ExtTools? maybe.
Post Reply