Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Run in same terminal #145

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

jesus2099
Copy link
Contributor

@jesus2099 jesus2099 commented Aug 9, 2023

Summary

Patching the Windows-only isrcsubmit.bat file.

Without this patch

  • The standard output is displayed in another temporary terminal window (no time to see it)
  • The script always pauses at the end, even when ran from the command line (odd and annoying)

With this patch

  • The standard output is displayed in current terminal window (like in Linux)
  • If the script is run from command line, there is no annoying pause at the end (like in Linux)

I have a new PC with Windows 10 Pro and the isrcsubmit.bat command is unfortunately:

  1. Launching isrcsubmit.py in new window
  2. Closing this new window as soon as the script is ended
  3. Pausing the parent window with nothing visible (as the script was run in new window, now closed)

Running python <path>\isrcsubmit.py instead of isrcsubmit.py fixes this problem.

I also fix the problem that work variable cp is added to environment variables.
I keep it local to the script, instead, with setlocal.


I have also added a code to pause the script only when launched from file explorer, with mouse, and not when launched from command line.

@jesus2099
Copy link
Contributor Author

Invite.de.commandes.2023-09-14.22-10-19.mp4

Here is what happens on my Windows 10 Professionnel 22H with Python 3.11.5.

First I run isrcsubmit_original.bat which is the original download.
You cannot see the new CMD.exe terminal window that appears and disappear with no time to read the output.
Then back on the original terminal with the pause message, for nothing.

Then I run my patched isrcsubmit.bat which displays output in same original terminal and that does not show useless pause message.

I will add a commit that enables a pause message, only when launching isrcsubmit.bat from mouse double-click, there it is needed.

@jesus2099
Copy link
Contributor Author

I have now added this code that will pause the script only when it is launched by mouse double-click (pause useful to see messages before terminal closes), and not when launched from CLI (pause useless):

echo %cmdcmdline%|findstr /c:"%~nx0" >nul
if %errorlevel% equ 0 echo.&pause

@jesus2099
Copy link
Contributor Author

jesus2099 commented Nov 27, 2023

Same on my new new office laptop:

  • Windows 10 Entreprise 22H2 x64
  • Python 3.11.6
  • Either CMD.exe or Windows Terminal

Maybe it's only an issue in Windows Terminal, No I reproduce same problem with CMD.exe right now, but anyway the new code is great because then the script pauses appropriately when run from mouse double-click from File Explorer and does not pause when run from a command line.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant