Skip to content

terminal-helper: remove scripts after execution - #89

Open
myakupozluk wants to merge 2 commits into
CachyOS:developfrom
myakupozluk:fix/retain-terminal-script
Open

terminal-helper: remove scripts after execution#89
myakupozluk wants to merge 2 commits into
CachyOS:developfrom
myakupozluk:fix/retain-terminal-script

Conversation

@myakupozluk

Copy link
Copy Markdown

Summary

  • keep the generated terminal script available until the shell running it completes
  • move cleanup into the generated script itself
  • clean up immediately only when a non-KGX terminal launcher fails to start
  • fix the launcher-error conditional so a successful non-KGX launch does not trigger cleanup

This prevents pkexec from receiving a path that has already been removed, notably with GNOME Console (kgx).

Closes #87

Validation

  • bash -n src/terminal-helper
  • exercised successful terminal execution with a mock alacritty; verified the command ran and its temporary script was removed afterwards
  • exercised terminal-launch failure; verified exit status 2 and immediate temporary-file cleanup
  • git diff --check

Copilot AI lite review requested due to automatic review settings September 9, 2026 14:50

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 Changes recommended

The newly appended cleanup line uses bash-specific %q quoting even though -s allows changing shells; switching to rm -f -- "$0" (and using rm -f -- in the immediate cleanup path) would make the behavior robust and portable.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

This PR adjusts src/terminal-helper so the temporary script used to launch privileged commands is not deleted until the terminal-run shell completes, preventing races where pkexec (or the wrapper script) is handed a path that has already been removed (notably affecting kgx/GNOME Console scenarios).

Changes:

  • Switch script content emission from echo to printf for predictable output/newline behavior.
  • Move temp-script cleanup into the generated script itself (self-cleaning after execution).
  • Fix the launcher-failure conditional so a successful non-kgx launch does not trigger cleanup/exit.
File summaries
File Description
src/terminal-helper Writes a self-cleaning temp script and adjusts terminal-launch failure handling to avoid removing the script before it is executed.
Review details
  • Files reviewed: 1/1 changed files
  • Comments generated: 1
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread src/terminal-helper Outdated
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
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.

cachyos-kernel-manager fails to execute kernel operations because temporary script is deleted before pkexec runs

2 participants