Summary of the new feature / enhancement
Note:
A fix for #19738 is being worked on in #19780, and it will delegate to /sbin/shutdown -h now (shutdown) and /sbin/shutdown -r now (reboot) on macOS.
However, these commands amount to a forced shutdown: they do not afford GUI applications enough time to shut down gracefully, such as browsers and VM software, inducing potential data loss.
Therefore, I propose the following:
Proposed technical implementation details (optional)
By default, use the following commands on macOS - they do shut down gracefully, but - as on Windows - do not guarantee a shutdown, if an app refuses to quit:
- Shutdown:
osascript -e 'tell application "System Events" to shut down'
- Reboot:
osascript -e 'tell application "System Events" to restart'
Use /sbin/shutdown ONLY if -Force is specified.
Note that the "graceful" commands do not require sudo, i.e. administrative privileges, whereas /sbin/shutdown always does.
Summary of the new feature / enhancement
Note:
This would not be a breaking change, because
Stop-ComputerandRestart-Computerare currently broken altogether on macOS - see Stop-Computer: broken on macOS; suboptimal UX on all Unix-like platforms #19738I do not know enough about Linux distros to tell if a distinction analogous to the one below is even possible or necessary there. Perhaps the answers here provide clues.
A fix for #19738 is being worked on in #19780, and it will delegate to
/sbin/shutdown -h now(shutdown) and/sbin/shutdown -r now(reboot) on macOS.However, these commands amount to a forced shutdown: they do not afford GUI applications enough time to shut down gracefully, such as browsers and VM software, inducing potential data loss.
Therefore, I propose the following:
Proposed technical implementation details (optional)
By default, use the following commands on macOS - they do shut down gracefully, but - as on Windows - do not guarantee a shutdown, if an app refuses to quit:
osascript -e 'tell application "System Events" to shut down'osascript -e 'tell application "System Events" to restart'Use
/sbin/shutdownONLY if-Forceis specified./sbin/shutdown -h now/sbin/shutdown -r nowNote that the "graceful" commands do not require
sudo, i.e. administrative privileges, whereas/sbin/shutdownalways does.