Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .agents/scripts/issue-sync-helper.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

set -euo pipefail

SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" || exit
SCRIPT_DIR="$(cd "${BASH_SOURCE[0]%/*}" && pwd)" || exit
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

critical

The parameter expansion ${BASH_SOURCE[0]%/*} can be problematic. If the script is invoked from the PATH without a directory prefix (e.g., myscript.sh instead of ./myscript.sh), this expansion results in the script's filename itself. The subsequent cd command will then fail because it's a file, not a directory.

A more robust approach is to check if the expansion modified the string and fall back to . if it didn't, which correctly handles all invocation scenarios.

Suggested change
SCRIPT_DIR="$(cd "${BASH_SOURCE[0]%/*}" && pwd)" || exit
dir="${BASH_SOURCE[0]%/*}"
if [[ "$dir" == "${BASH_SOURCE[0]}" ]]; then
dir="."
fi
SCRIPT_DIR="$(cd "$dir" && pwd)" || exit

source "${SCRIPT_DIR}/shared-constants.sh"
# shellcheck source=issue-sync-lib.sh
source "${SCRIPT_DIR}/issue-sync-lib.sh"
Expand Down
2 changes: 1 addition & 1 deletion .agents/scripts/issue-sync-lib.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ _ISSUE_SYNC_LIB_LOADED=1
# Source shared-constants.sh to make the library self-contained.
# Resolves SCRIPT_DIR from BASH_SOURCE so it works when sourced from any location.
if [[ -z "${SCRIPT_DIR:-}" ]]; then
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
SCRIPT_DIR="$(cd "${BASH_SOURCE[0]%/*}" && pwd)"
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

critical

The parameter expansion ${BASH_SOURCE[0]%/*} can be problematic. If the script is invoked from the PATH without a directory prefix (e.g., myscript.sh instead of ./myscript.sh), this expansion results in the script's filename itself. The subsequent cd command will then fail because it's a file, not a directory.

A more robust approach is to check if the expansion modified the string and fall back to . if it didn't, which correctly handles all invocation scenarios.

Suggested change
SCRIPT_DIR="$(cd "${BASH_SOURCE[0]%/*}" && pwd)"
dir="${BASH_SOURCE[0]%/*}"
if [[ "$dir" == "${BASH_SOURCE[0]}" ]]; then
dir="."
fi
SCRIPT_DIR="$(cd "$dir" && pwd)"

fi
source "${SCRIPT_DIR}/shared-constants.sh"

Expand Down
2 changes: 1 addition & 1 deletion .agents/scripts/session-miner-pulse.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ set -euo pipefail

# --- Configuration ---

SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
SCRIPT_DIR="$(cd "${BASH_SOURCE[0]%/*}" && pwd)"
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

critical

The parameter expansion ${BASH_SOURCE[0]%/*} can be problematic. If the script is invoked from the PATH without a directory prefix (e.g., myscript.sh instead of ./myscript.sh), this expansion results in the script's filename itself. The subsequent cd command will then fail because it's a file, not a directory.

A more robust approach is to check if the expansion modified the string and fall back to . if it didn't, which correctly handles all invocation scenarios.

Suggested change
SCRIPT_DIR="$(cd "${BASH_SOURCE[0]%/*}" && pwd)"
dir="${BASH_SOURCE[0]%/*}"
if [[ "$dir" == "${BASH_SOURCE[0]}" ]]; then
dir="."
fi
SCRIPT_DIR="$(cd "$dir" && pwd)"

MINER_DIR="${HOME}/.aidevops/.agent-workspace/work/session-miner"
# Shipped with aidevops; copied to workspace on first run
EXTRACTOR_SRC="${SCRIPT_DIR}/session-miner/extract.py"
Expand Down