Skip to content

Commit 2b5508d

Browse files
committed
fix: improve cross-platform shell compatibility
1 parent 3c88157 commit 2b5508d

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

scripts/doctor.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,12 +83,12 @@ fi
8383

8484
commands_count=0
8585
if [ -d "$COMMANDS_DIR" ]; then
86-
commands_count=$(find "$COMMANDS_DIR" -maxdepth 1 -name '*.md' | wc -l | tr -d ' ')
86+
commands_count=$(find "$COMMANDS_DIR" -type f -name '*.md' 2>/dev/null | wc -l | tr -d ' ')
8787
fi
8888

8989
pending_count=0
9090
if [ -d "$PENDING_DIR" ]; then
91-
pending_count=$(find "$PENDING_DIR" -maxdepth 1 -name '*.json' | wc -l | tr -d ' ')
91+
pending_count=$(find "$PENDING_DIR" -type f -name '*.json' 2>/dev/null | wc -l | tr -d ' ')
9292
fi
9393

9494
profile_belt="unknown"

scripts/session-stop.sh

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,14 @@ if [ -d "$PENDING_DIR" ] && [ "$(ls -A "$PENDING_DIR" 2>/dev/null)" ]; then
8080
# Clear the pending queue
8181
rm -f "$PENDING_DIR"/*.json
8282

83-
# Cap archive size: keep only last 30 days of archives (~1MB)
84-
find "$ARCHIVE_DIR" -name "*.jsonl" -type f | sort | head -n -30 | xargs -r rm -f
83+
# Cap archive size: keep only the latest 30 daily archives
84+
ARCHIVE_COUNT=$(find "$ARCHIVE_DIR" -name "*.jsonl" -type f | wc -l | tr -d ' ')
85+
if [ "$ARCHIVE_COUNT" -gt 30 ]; then
86+
REMOVE_COUNT=$((ARCHIVE_COUNT - 30))
87+
find "$ARCHIVE_DIR" -name "*.jsonl" -type f | sort | head -n "$REMOVE_COUNT" | while IFS= read -r archive_file; do
88+
[ -n "$archive_file" ] && rm -f "$archive_file"
89+
done
90+
fi
8591
fi
8692

8793
rm -f "$SESSION_STATE"

0 commit comments

Comments
 (0)