Skip to content

Commit 2cdcfff

Browse files
Rubiczhangclaude
andcommitted
refactor(bitlesson): simplify extracted scripts
- Collapse intermediate boolean into direct grep test in validate-delta - Replace IFS save/restore with scoped IFS on read in validate-delta - Remove redundant -s check (subset of whitespace-only check) in select Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent e3e1019 commit 2cdcfff

2 files changed

Lines changed: 2 additions & 15 deletions

File tree

scripts/bitlesson-select.sh

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -86,11 +86,6 @@ if [[ ! -f "$BITLESSON_FILE" ]]; then
8686
exit 1
8787
fi
8888

89-
if [[ ! -s "$BITLESSON_FILE" ]]; then
90-
echo "Error: BitLesson file is empty: $BITLESSON_FILE" >&2
91-
exit 1
92-
fi
93-
9489
BITLESSON_CONTENT="$(cat "$BITLESSON_FILE")"
9590
if [[ -z "$(printf '%s' "$BITLESSON_CONTENT" | tr -d ' \t\n\r')" ]]; then
9691
echo "Error: BitLesson file is empty (whitespace only): $BITLESSON_FILE" >&2

scripts/bitlesson-validate-delta.sh

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -89,12 +89,7 @@ block_exit() {
8989
exit 0
9090
}
9191

92-
HAS_BITLESSON_DELTA_HEADER=false
93-
if grep -qi '^##[[:space:]]*BitLesson Delta[[:space:]]*$' "$SUMMARY_FILE"; then
94-
HAS_BITLESSON_DELTA_HEADER=true
95-
fi
96-
97-
if [[ "$HAS_BITLESSON_DELTA_HEADER" != "true" ]]; then
92+
if ! grep -qi '^##[[:space:]]*BitLesson Delta[[:space:]]*$' "$SUMMARY_FILE"; then
9893
FALLBACK=$(cat <<'EOF'
9994
# BitLesson Delta Missing
10095
@@ -215,10 +210,7 @@ EOF
215210
INVALID_IDS=""
216211
MISSING_IDS=""
217212
HAS_ANY_ID=false
218-
OLD_IFS="$IFS"
219-
IFS=','
220-
read -r -a LESSON_ID_ARRAY <<< "$BITLESSON_IDS_RAW"
221-
IFS="$OLD_IFS"
213+
IFS=',' read -r -a LESSON_ID_ARRAY <<< "$BITLESSON_IDS_RAW"
222214

223215
for RAW_ID in "${LESSON_ID_ARRAY[@]}"; do
224216
LESSON_ID=$(echo "$RAW_ID" | sed 's/^[[:space:]]*//; s/[[:space:]]*$//')

0 commit comments

Comments
 (0)