Skip to content

Commit

Permalink
fix Update todo_tree.sh
Browse files Browse the repository at this point in the history
  • Loading branch information
voronor authored Jan 26, 2025
1 parent 88ed67c commit 7184c44
Showing 1 changed file with 13 additions and 11 deletions.
24 changes: 13 additions & 11 deletions scripts/todo_tree.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,19 @@ scan_todos() {
exit 1
fi

# Build the find command based on whether an extension is provided
local find_cmd="find \"$dir\" -type f"
if [ -n "$ext" ]; then
find_cmd+=" -name \"*.$ext\""
fi
if [ -n "$max_depth" ]; then
find_cmd+=" -maxdepth $max_depth"
fi
# Build the find command using an array
local find_cmd=(find "$dir" -type f)
if [ -n "$ext" ]; then
find_cmd+=(-name "*.$ext")
fi
if [ -n "$max_depth" ]; then
find_cmd+=(-maxdepth "$max_depth")
fi

# Execute the find command and process the files
eval $find_cmd | while read -r file; do
# Execute the find command and process the files
"${find_cmd[@]}" | while read -r file; do
...
done
# Search for TODO/FIXME and group results by file
matches=$(grep -n -E "TODO|FIXME" "$file")
if [ -n "$matches" ]; then
Expand All @@ -48,4 +50,4 @@ extension=$2 # If empty, all files will be scanned
max_depth=${3:-} # No depth limit if not provided

# Call the function
scan_todos "$directory" "$extension" "$max_depth"
scan_todos "$directory" "$extension" "$max_depth"

0 comments on commit 7184c44

Please sign in to comment.