fix: use space-padded regex for cd-prefix stripping
Updates the cd-prefix stripping regex to require a space before the delimiter (&& or ;). This allows paths containing & or ; characters to be matched correctly while still finding the command separator. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
3575643473
commit
367f1484c6
|
|
@ -128,8 +128,9 @@ update_metadata_key() {
|
|||
# Strip leading directory-change prefixes so that commands like
|
||||
# cd ~/.worktrees/project && gh pr create ...
|
||||
# are correctly detected. Agents frequently cd into a worktree first.
|
||||
# Store the regex pattern in a variable for clarity (avoids shell quoting confusion)
|
||||
cd_prefix_pattern='^[[:space:]]*cd[[:space:]]+[^&;]*[[:space:]]*(&&|;)[[:space:]]*(.*)'
|
||||
# Store the regex pattern in a variable for clarity (avoids shell quoting confusion).
|
||||
# Uses space-padded (&&|;) to avoid breaking on paths containing & or ; chars.
|
||||
cd_prefix_pattern='^[[:space:]]*cd[[:space:]]+.*[[:space:]]+(&&|;)[[:space:]]+(.*)'
|
||||
clean_command="$command"
|
||||
while [[ "$clean_command" =~ ^[[:space:]]*cd[[:space:]] ]]; do
|
||||
if [[ "$clean_command" =~ $cd_prefix_pattern ]]; then
|
||||
|
|
|
|||
Loading…
Reference in New Issue