d0vgan / nppexec

NppExec (plugin for Notepad++)

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Possible regression 20220128 dev build

vinsworldcom opened this issue · comments

commented

See here:

I have a global set:

SET CMD=cmd.exe /d /c

And I use it in scripts - for example:

$(CMD) start $(NPP_DIRECTORY)\change.log

and this launches Notepad.exe (my default .log editor apparently) with change.log.

In the new version, running that second script - nothing happens. It seems the $(CMD) variable isn’t launching external processes anymore? Other things like:

$(CMD) dir /b /ad $(NPP_DIRECTORY)

do work. The previous 0.7.1 version of NppExec did fine launching the external processes.

Cheers.

Heck, it contradicts with this! -- #60
In particular, it contradicts with this approach:
https://stackoverflow.com/questions/24012773/c-winapi-how-to-kill-child-processes-when-the-calling-parent-process-is-for/24020820
To sum up, we most likely want this behavior in case of a console child process running from a root process; and we most likely do not want it in case of a GUI child process running from a root process.
How to handle both cases? I don't know...

commented

Well, I think the old behavior needs to be preserved by default - to be consistent with the standard command prompt.
And the new one, where the process tree is killed, will be enabled e.g. by npe_console j+.

commented

Happy to test when available.

This bug have nothing to do with ctrl-c behavior described here #60
it happens in the default dll of 20220128 dev build
and it is caused by the new feature of killing the childs
in fact notepad open then close quickly like that:
you run

$(CMD) start $(NPP_DIRECTORY)\change.log

then cmd exit, then Nppexec will kill notepad thanks to the new feature (killing the childs)

so this is a feature not a bug I think.

it can be solved easily by adding /wait flag so cmd do no exit:

$(CMD) start /wait $(NPP_DIRECTORY)\change.log

or it can be solved by using npp_run:

npp_run $(CMD) start $(NPP_DIRECTORY)\change.log

or simply

npp_run $(NPP_DIRECTORY)\change.log
commented

Indeed, the /wait to the start command seems to fix it - in some cases.

I have a script:

::relaunch
NPP_CONSOLE disable
NPP_EXEC date
NPP_EXEC time
NPP_CONSOLE enable
SET LOCAL TIMESTAMP = $(DATE)$(TIME)
SET LOCAL TEMPFILE = "$(SYS.TEMP)\session_$(TIMESTAMP).nps"
NPP_EXEC save session $(TEMPFILE)
$(CMD) start $(POWERSHELL) "Start-Sleep 3; $(NPP_DIRECTORY)\notepad++.exe -openSession $(TEMPFILE)"
// $(CMD) start powershell -NoProfile -Command "Read-Host -Prompt 'Press Enter to launch Notepad++'; $(NPP_DIRECTORY)\notepad++.exe -openSession $(NPP_DIRECTORY)\session.xml"
NPP_EXEC exit

which breaks. I need to launch the PowerShell and let it continue running while the NppExec script continues to run and exists Notepad++ , which the PowerShell re-opens. This script works find in NppExec 0.7.1, but fails in the new version and adding the /wait doesn't help as it waits for the powershell to complete and then continues - which exits Notepad++ defeating the purpose.

I like the idea above of :

"old behavior needs to be preserved by default - to be consistent with the standard command prompt.
And the new one, where the process tree is killed, will be enabled e.g. by npe_console j+."

Cheers.

@d0vgan

Well, I think the old behavior needs to be preserved by default - to be consistent with the standard command prompt.
And the new one, where the process tree is killed, will be enabled e.g. by npe_console j+

you are right, new comers will think that NppExec do not work, the feature of killing childs should be enabled when needed not by default to be consistent with the standard command prompt as you said.

@vinsworldcom
your case can be solved by using npp_run $(POWERSHELL)... instead of $(CMD) start $(POWERSHELL)...

npp_run is not affected by the new feature (killing childs)

commented

YES - you're right, just tested.

Thank you @badrelmers and @d0vgan for the help. I LOVE this plugin - evidence my 2850+ line npes_saved.txt!

commented

@badrelmers , @d0vgan took some time yesterday to go through my large npes_saved.txt and it seems there are many places where I can replace cmd.exe /d /c => $(CMD) for NPP_RUN ... and things work as expected. I use the $(CMD) to run "Batch" commands like if exist ..., for /f %i in ... but was also using it to "launch" applications like $(CMD) explorer.exe ... which it seems are better suited to NPP_RUN ....

Thanks for your patience and help - I use this plugin everyday I'm in Notepad++ to automate so many tasks yet I still seem to have only scratched the surface of understanding what's possible or the best way to implement things.

Cheers.

yes d0vgan really made a good work, he made the beautiful Notepad++ to become something more beautiful. thanks to him and his time and nice work

NPE_CONSOLE j+/j- works perfectly
this is great, thank you so much d0vgan