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.
Shellcheck Tool and Shell Command Checkbox
-
main Alexey
- Posts: 2863
- Joined: 25.08.2021 18:15
Re: Shellcheck Tool and Shell Command Checkbox
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.
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
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
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
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:
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.
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}")'
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
> 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.
that is the question for all users, not exactly for me. I only can guess something.
do you know this ExtTools macro? can you use it to replace bash-input-redirection?{SelectionAsTemp} - Name of [temporary] file with selected text
-
Random Void User
- Posts: 84
- Joined: 13.07.2024 21:19
Re: Shellcheck Tool and Shell Command Checkbox
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:
This experiment did not work, but did not emit errors.
Code: Select all
--all --unicode=default --encoding=S --bytes=1 "{SelectionAsTemp}"
-
main Alexey
- Posts: 2863
- Joined: 25.08.2021 18:15
Re: Shellcheck Tool and Shell Command Checkbox
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.
I don't know why. this is interesting.
bug in the ExtTools? maybe.