Skip to content

Conversation

@WhatDamon
Copy link
Contributor

@WhatDamon WhatDamon commented Dec 5, 2025

Close #4925

image

语言文件可能需要帮助

@WhatDamon WhatDamon changed the title 在 macOS 上将添加启动脚本的后缀 .command 在 macOS 上添加启动脚本的后缀 .command Dec 5, 2025
extension.png=Image File
extension.ps1=Windows PowerShell Script
extension.sh=Shell Script
extension.command=macOS Command Script
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
extension.command=macOS Command Script
extension.command=macOS Shell Script

extension.png=圖片檔案
extension.ps1=PowerShell 指令碼
extension.sh=Bash 指令碼
extension.command=macOS Command 指令碼
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
extension.command=macOS Command 指令碼
extension.command=macOS Shell 指令碼

extension.png=图片文件
extension.ps1=PowerShell 脚本
extension.sh=Bash 脚本
extension.command=macOS Command 脚本
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
extension.command=macOS Command 脚本
extension.command=macOS Shell 脚本

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This pull request adds support for the .command file extension for launch scripts on macOS. The .command extension is natively recognized by macOS as executable and can be double-clicked in Finder to run, making it more user-friendly than .sh files which require terminal access or explicit permission changes.

Key Changes:

  • Extended script validation logic to accept .command extension alongside .sh for non-Windows platforms
  • Added .command option to the file chooser dialog specifically for macOS users
  • Added localization strings for "macOS Shell Script" in English, Simplified Chinese, and Traditional Chinese

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
HMCLCore/src/main/java/org/jackhuang/hmcl/launch/DefaultLauncher.java Updated validation logic to accept both 'sh' and 'command' extensions for Unix-like systems, with corresponding error message update
HMCL/src/main/java/org/jackhuang/hmcl/ui/versions/Versions.java Added .command extension filter option to file chooser dialog for macOS users, positioned before other options for better discoverability
HMCL/src/main/resources/assets/lang/I18N.properties Added English localization string for .command file extension
HMCL/src/main/resources/assets/lang/I18N_zh_CN.properties Added Simplified Chinese localization string for .command file extension
HMCL/src/main/resources/assets/lang/I18N_zh.properties Added Traditional Chinese localization string for .command file extension

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

else if (!isWindows && !scriptExtension.equals("sh"))
throw new IllegalArgumentException("The extension of " + scriptFile + " is not 'sh' or 'ps1' in macOS/Linux");
else if (!isWindows && !(scriptExtension.equals("sh") || scriptExtension.equals("command")))
throw new IllegalArgumentException("The extension of " + scriptFile + " is not 'sh', 'ps1' or 'command' in macOS/Linux");
Copy link

Copilot AI Dec 9, 2025

Choose a reason for hiding this comment

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

The error message states that the extension should be 'sh', 'ps1' or 'command' in macOS/Linux, but this error is only thrown when usePowerShell is false (line 609). This means if we reach this error, the extension is definitely NOT 'ps1', making the mention of 'ps1' in the error message confusing or misleading to users.

Note: This is a pre-existing issue also present in the Windows error message on line 611. Consider removing 'ps1' from both error messages, or restructuring the validation logic to provide clearer error messages.

Copilot uses AI. Check for mistakes.
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.

[Feature] 在 macOS 上将启动脚本的后缀改为 .command

2 participants