Skip to content

fix(vscode-theme): replace legacy prompt command substitution - #777

Open
Mr-qolamii wants to merge 1 commit into
ohmybash:masterfrom
Mr-qolamii:fix-vscode-theme-bash-prompt
Open

Mr-qolamii wants to merge 1 commit into
ohmybash:masterfrom
Mr-qolamii:fix-vscode-theme-bash-prompt

Conversation

@Mr-qolamii

Copy link
Copy Markdown

Replace backtick-based command substitution with PROMPT_COMMAND to prevent Bash export parsing errors and improve compatibility with modern Bash versions.

Replace backtick-based command substitution with PROMPT_COMMAND
to prevent Bash export parsing errors and improve compatibility
with modern Bash versions.
@qodo-free-for-open-source-projects

Copy link
Copy Markdown

PR Summary by Qodo

Build VS Code theme prompt with PROMPT_COMMAND

🐞 Bug fix 🕐 10-20 Minutes

Grey Divider

AI Description

• Rebuilds VS Code theme prompts through PROMPT_COMMAND instead of legacy backtick substitutions.
• Preserves user, exit-status, Git branch, dirty-state, and directory prompt rendering.
Diagram

graph TD
  A["Prompt cycle"] --> B["Prompt function"] --> C{"Show Git?"}
  C -->|Yes| D["Git context"] --> F["Prompt builder"] --> G["PS1 output"]
  C -->|No| F
  B --> E["User and status"] --> F
Loading
High-Level Assessment

The following are alternative approaches to this PR:

1. Register with the prompt utility
  • ➕ Uses the repository's established prompt-hook abstraction
  • ➕ Preserves scalar and array PROMPT_COMMAND values across Bash versions
  • ➕ Centralizes duplicate-hook prevention and compatibility handling
  • ➖ Routes execution through the shared prompt dispatcher
  • ➖ Requires naming and registering the callback using existing theme conventions

Recommendation: Keep the dedicated prompt-building function, but prefer registering it through _omb_util_add_prompt_command rather than assigning PROMPT_COMMAND directly. The shared utility already handles Bash 5.1 array-form PROMPT_COMMAND values, older scalar forms, existing hooks, and duplicate registration, which better matches the stated modern-Bash compatibility goal.

Files changed (1) +47 / -21

Bug fix (1) +47 / -21
vscode.theme.shRebuild the VS Code prompt from a prompt callback +47/-21

Rebuild the VS Code prompt from a prompt callback

• Replaces PS1-embedded backtick substitutions with a function invoked through PROMPT_COMMAND. The function captures the previous exit status, resolves the displayed user and Git state, colors the prompt arrow, and reconstructs PS1 while retaining PROMPT_DIRTRIM behavior.

themes/vscode/vscode.theme.sh

@qodo-free-for-open-source-projects

Copy link
Copy Markdown

Code Review by Qodo

🐞 Bugs (1) 📘 Rule violations (0) 📜 Skill insights (0)

Grey Divider


Action required

1. Existing prompt hooks are lost 🐞 Bug ☼ Reliability
Description
On Bash 5.1+, line 65 expands only element zero of an array-valued PROMPT_COMMAND and replaces the
array with a scalar, so all later prompt hooks stop executing. Re-sourcing the theme also prepends
duplicate invocations because this direct registration has no deduplication.
Code

themes/vscode/vscode.theme.sh[65]

+PROMPT_COMMAND="_omb_theme_vscode_prompt${PROMPT_COMMAND:+;$PROMPT_COMMAND}"
Evidence
The changed theme line performs a scalar reconstruction of PROMPT_COMMAND. The framework's
standard registration utility explicitly deduplicates registrations and, for Bash 5.1+, iterates
existing array entries and appends rather than converting the variable to a scalar, proving this
direct assignment bypasses required compatibility behavior.

themes/vscode/vscode.theme.sh[65-65]
lib/utils.sh[361-366]
lib/utils.sh[389-397]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
Registering the VS Code prompt via scalar assignment destroys later entries in an array-valued `PROMPT_COMMAND` on Bash 5.1+ and duplicates the hook when the theme is sourced again.

## Issue Context
The repository already provides `_omb_util_add_prompt_command`, which deduplicates hooks and handles both legacy scalar and modern array forms of `PROMPT_COMMAND`.

## Fix Focus Areas
- themes/vscode/vscode.theme.sh[65-65]
- lib/utils.sh[361-397]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


Grey Divider

Tip of the day
💡 Did you know, you can enable the Remediation agent and Qodo fixes findings in a dedicated fix PR

More tips ↗ | Customize Qodo ↗ | Qodo docs ↗

Grey Divider

Qodo Logo

Comment thread themes/vscode/vscode.theme.sh
_omb_theme_vscode_initialize

function _omb_theme_PROMPT_COMMAND { true; }
PROMPT_COMMAND="_omb_theme_vscode_prompt${PROMPT_COMMAND:+;$PROMPT_COMMAND}"

@akinomyoga akinomyoga Aug 30, 2026 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This isn't expected. See the other themes registering _omb_theme_PROMPT_COMMAND.

@akinomyoga

akinomyoga commented Aug 30, 2026 •

Copy link
Copy Markdown
Contributor

to prevent Bash export parsing errors

What are the "Bash export parsing errors"?

and improve compatibility with modern Bash versions.

What is the compatibility improvement? Bash is basically backward-compatible.

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.

2 participants