2

I'm using external tool to run fuser -k 1099 command before actually launching my run configuration before launch But if external tool returns non-zero status, build configuration stops. That is perfectly correct, but I can not find any way to ignore failure. If it was a plain bash, I'd do something like fuser -k 1099 || true. But at Idea, that seems to be not possible

external tool configuration

Any ideas?

Dmitriusan
  • 11,525
  • 3
  • 38
  • 38
  • Wrap it into a bash script and always return zero exit code from it? – CrazyCoder May 22 '18 at 19:20
  • hm, it might work! Even without script, just by `bash -c 'fuser -k 1099'; true` . I did not think in this direction, expected Idea to provide some option to skip failure of external tool. Thanks! – Dmitriusan May 23 '18 at 09:23
  • If you post your comment as answer, I'll mark it as accepted – Dmitriusan May 23 '18 at 09:24

2 Answers2

3

You can use /bin/bash as the program and the following as the arguments:

-c 'fuser -k 1099'; true

This way the exit code of the tool will be always zero.

CrazyCoder
  • 389,263
  • 172
  • 990
  • 904
  • This was the only issue/solution I could find relevant to what I was running into trying to run a bash command in the external tool. However, defining: -c " && "; true Would not work for me. IntelliJ kept putting the ";" inside the quotes for some reason... I had to individually set each command inside the quotes with a "; true" and then it worked. Hope this helps someone else – rwarner Nov 26 '19 at 16:18
  • Same here under Windows, putting `cmd` in `Program` and `/c taskkill /IM my.exe /F & set errorlevel=0` in `Arguments` (if I run `cmd /c taskkill /IM my.exe /F & set errorlevel=0` in a command prompt I got error that my.exe does not run but `errorlevel` is actually `0`, but from IntelliJ it seems & is taken as a taskkill argument instead of the next command since I got `ERROR: Invalid argument/option - '&'. Type "TASKKILL /?" for usage.`, I tried with call or putting a `if 1 == 1` before `taskkill /IM my.exe /F & set errorlevel=0` and some other things without success... – gluttony Feb 14 '22 at 13:58
0

Correct answer was not working for me (see my comment under it) I then found a solution that is to create a script that exits with 0, here under windows (let us call it KillMyExeNoError.bat):

taskkill /IM my.exe /F
exit /B 0

Then put C:\Path\To\KillMyExeNoError.bat in Program and leave Arguments empty.

Maybe under Linux you need to put bash in Program and /path/to/script.sh in Arguments.

Not the best solution since it would be good not to have to create a separate script but at least it works.

gluttony
  • 402
  • 6
  • 14