Skip to content

Conversation

@gurelkaynak
Copy link

@gurelkaynak gurelkaynak commented Sep 30, 2025

User description

Fixes #716


PR Type

Bug fix


Description

  • Fixed unbound variable error in directory stack handling

  • Added parameter expansion with default value to prevent bash error


Diagram Walkthrough

flowchart LR
  A["Array Access"] -- "Add Default Value" --> B["Safe Parameter Expansion"]
  B -- "Prevents" --> C["Unbound Variable Error"]
Loading

File Walkthrough

Relevant files
Bug fix
directories.sh
Fix unbound variable in directory stack array                       

lib/directories.sh

  • Added parameter expansion with default value to _omb_cd_dirstack[0]
  • Changed ${_omb_cd_dirstack[0]} to ${_omb_cd_dirstack[0]-}
  • Prevents unbound variable error when array is empty
+1/-1     

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

PR Reviewer Guide 🔍

Here are some key observations to aid the review process:

🎫 Ticket compliance analysis 🔶

716 - Partially compliant

Compliant requirements:

  • Prevent 'unbound variable' error for _omb_cd_dirstack[0] in non-interactive shells.
  • Implement a safe guard consistent with 'nounset' environments.

Non-compliant requirements:

  • Ensure cd works reliably without breaking existing directory stack behavior.

Requires further human verification:

  • Verify interactively and in non-interactive shells (e.g., Cursor agent) that cd works and directory stack behavior remains unchanged.
  • Test with set -u enabled to confirm no regressions elsewhere in directories.sh.
⏱️ Estimated effort to review: 1 🔵⚪⚪⚪⚪
🧪 No relevant tests
🔒 No security concerns identified
⚡ Recommended focus areas for review

Behavior Change

Confirm that using ${_omb_cd_dirstack[0]-} preserves previous logic when the array is empty and does not inadvertently skip prepending $PWD or alter DIRSTACK semantics in edge cases.

[[ ${_omb_cd_dirstack[0]-} == "$PWD" ]] ||
  _omb_cd_dirstack=("$PWD" "${_omb_cd_dirstack[@]}")
builtin cd "$@" &&
  _omb_cd_dirstack=("$PWD" "${_omb_cd_dirstack[@]}")

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

PR Code Suggestions ✨

No code suggestions found for the PR.

@rockiesmagicnumber
Copy link

If we could get this reviewed that would be superduper so I can get back on master :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

cd not working in shells created by cursor

2 participants