Skip to content

♻️ Use .sh extension on shell compatible terminals on Windows#196

Closed
teikitel wants to merge 1 commit into
criteo:mainfrom
teikitel:main
Closed

♻️ Use .sh extension on shell compatible terminals on Windows#196
teikitel wants to merge 1 commit into
criteo:mainfrom
teikitel:main

Conversation

@teikitel
Copy link
Copy Markdown
Contributor

@teikitel teikitel commented Apr 8, 2026

On Windows with Git Bash, when hitting CTRL+C when running for example a java CLI from command launcher, the terminal crashes because the underlying execution is actually passed down a .bat script execution.

In Git Bash, we actually don't need to use the .bat version. The .sh version will even be more efficient.

To detect that we're in Git Bash, we use the environment variable MSYSTEM.

Here we also rename occurrences of "os" used as OS name "osName" to avoid confusions with the "os" library.

Change-Id: I5bed4dc2282533d75bceccba67ad05b9c1094f0d

On Windows with Git Bash, when hitting CTRL+C when running for example a java CLI from command launcher, the terminal crashes because the underlying execution is actually passed down a .bat script execution.

In Git Bash, we actually don't need to use the .bat version. The .sh version will even be more efficient.

To detect that we're in Git Bash, we use the environment variable MSYSTEM.

Here we also rename occurrences of "os" used as OS name "osName" to avoid confusions with the "os" library.

Change-Id: I5bed4dc2282533d75bceccba67ad05b9c1094f0d
@hdost hdost assigned hdost and bhou Apr 8, 2026
Copy link
Copy Markdown
Contributor

@bhou bhou left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't have a windows environment at hand, I am wondering the situation in WSL environment, what will be the osName, and should we handle it here as well? But that could be another PR.

@ndrufin-crto
Copy link
Copy Markdown
Contributor

I don't have a windows environment at hand, I am wondering the situation in WSL environment, what will be the osName, and should we handle it here as well? But that could be another PR.

In WSL the OS name is Unix based like Ubuntu.

@teikitel
Copy link
Copy Markdown
Contributor Author

In fact I test on Windows and it's not enough.

As the command launcher is a native process, the underlying subcommand is forked as native process.

  • Launching a command with no extension will cause Windows process to try and find a .bat or .exe associated file
  • Launching a bash script with .sh extension will fail because .sh is not a valid executable extension

I'll push another approach to handle signals from command-launcher and allow for a more graceful shutdown.

@teikitel teikitel closed this Apr 10, 2026
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.

4 participants