I have started using the plugin with my PHPStorm IDE. I have set up a configuration but whenever I run it I always have a double dash “–” appearing between the script name and the parameters I give which nullifies all parameters.
I’m sorry for the difficulties using the plugin.
Could you post a screenshot of the run configuration? That would help to understand what might be be wrong. Thanks!
“Debug” only situation I can think of where a -- is automatically added to the command line to support custom arguments, but it shouldn’t change the arguments received by your script. man bash:
– signals the end of options and disables further option processing. Any arguments after the – are treated as filenames and arguments. An argument of - is equivalent to --.
But there seems to be a bug, I suppose. The following should help me:
Could you post a screenshot of the output panel when you run the script, please? Scroll it to the top before you take it. For example:
PhpStorm 2021.3.3
Build #PS-213.7172.28, built on March 17, 2022
Licensed to USU Software AG / Stephen Hyde
Subscription is active until June 24, 2022.
Runtime version: 11.0.14.1+1-b1751.46 amd64
VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o.
Linux 5.4.0-104-generic
GC: G1 Young Generation, G1 Old Generation
Memory: 8000M
Cores: 12
Registry:
debugger.watches.in.variables=false
run.processes.with.pty=TRUE
Thank you for the details!
Unless you want to debug the script, using Run prepare-release instead of Debug prepare-release should help (via context menu or by clicking the green arrow instead of the debug icon).
I’m not sure why -- breaks script execution, because it’s supposed to be a standard Bash feature. I’ll debug that on Ubuntu and release an update of 2.1.x which doesn’t add -- if I find that debugging is still working on all supported operating systems and versions of Bash.
Isn’t it the case though that – prevents all further parameters being used, and if all parameters by default in debugging mode come after the – then they are all useless?
It’s hard to say what I see in the script. Line 79 which is where it says the error comes from is actually the middle of a very large variable that shows parameters for the script that is echoed out elsewhere
Thanks for testing! Unfortunately, this problem seems difficult to find. It’s still possible that it’s caused by the debugger, but I probably won’t be able to fix it without a better understanding what’s going on.
You could try to add a breakpoint on line 78 or 79 and then evaluate expressions to find out more about what it’s doing and what might be wrong.
Is the error Error while on line 79 printed by your script? I don’t think it’s emitted by the debugger itself or BashSupport Pro.
Could you perhaps describe which commands are executed on line 79 or what that line is doing? Feel free to email that to mail@bashsupport.com if you don’t want to post it here.
It’s been a while since I raised this issue however I’ve been doing a large amount of refactoring on the affected script lately and I might have a case that you can use to test. The following code run with the debug button (i.e. no other custom configuration set) gives me the same error as before:
#!/bin/bash
errorexit() {
local msg="${1}"
echo “${0}: Error while ${msg} on line ${BASH_LINENO[$i]}” >&2
trap ERR
exit 1
}
trap errorexit ERR
gives:
/bin/bash /home/adishyde/.local/share/JetBrains/PhpStorm2022.1/bashsupport-pro/bashdb/5.0/bashdb --quiet --no-highlight --library /home/adishyde/.local/share/JetBrains/PhpStorm2022.1/bashsupport-pro/bashdb/5.0/share/bashdb --tty_in DBG_PTY --tty DBG_PTY /home/adishyde/.config/JetBrains/PhpStorm2022.1/scratches/scratch_13.sh
hi
/home/adishyde/.config/JetBrains/PhpStorm2022.1/scratches/scratch_13.sh: Error while on line 79
Thanks for the snippet! That helped to reproduce it, I’ll investigate and hope to be able to provide a fix. It’s most likely something internal of bashdb.
First of all, the ERR trap function was printing the source, where errorexit was defined.
If you pass $BASH_SOURCE as part of the code called as trap handler, then you could capture the file, where the error occurs.
With the fix, it’ll print that the erroneous file is /home/user/.local/share/JetBrains/Toolbox/apps/IDEA-U/ch-3/222.3345.16.plugins/bashsupport-pro/bashdb/5.0/share/bashdb/lib/hook.sh, which is part of bashdb.
The exit code of shopt is non-zero if nullglob isn’t set, which then triggers your ERR trap, which then terminates the script.
This could be fixed in bashdb itself, but there are more than a few lines like this.
Changes to upstream bashdb would take a while and have to be made carefully. I’m not sure yet if I’ll do that.
I recommend the following changes to ignore errors, which are part of the bashdb sources.
Does this work for you?
#!/bin/bash
errorexit() {
local file="$1"
local line="$2"
local error="$3"
echo "$file: Error $error on line $line" >&2
trap ERR
if [[ "$file" != *'/bashdb/'* ]]; then exit 1; fi
}
trap 'errorexit ${BASH_SOURCE[0]} $LINENO $?' ERR
I have found same behavior when I have tried to debug script where short and long arguments could be used in same time. Before my first test case I was able to see arguments in debugger when my command startet with -a followed by start, but after I have change first argument to --action start , even after reverting to -a start, bash support pro keep calling script with – at the beginning. Deleting and creating new configuration doesn’t help to reset plugin.
P.S.
I am running debugger from Intellij not PHPStorm
P.S.S
Now I have reinstalled a plugin, but problem still exists.
@Matiako Could you post the complete command line, which is used to launch the debugger? That’s the command line, which contains the -- argument your script doesn’t like.
Could you also post a screenshot of the run configuration settings, please?
In general, -- is passed to the Bash debugger to tell it that all following arguments are for the debugged script and not for the debugger itself.
@Matiako Thanks!
Could you describe what exactly is wrong when you launch the script with the debugger? A screenshot of the debugger panel or something similar may help me to debug this. So far I wasn’t able to reproduce it.
Are there problems with a TRAP handler as discussed in the thread above? If that’s the case, did the workaround posted above help?
Or is this about a literal -- passed as an argument to your script? In this case it may be an issue with WSL or the WSL integration. In general Bash 5 works best for debugging, but I suppose that Oracle Linux doesn’t provide it.