Skip to content

~95% on SimpleQA (e.g. Qwen3.6-27B on a 3090). Supports all local and cloud LLMs (llama.cpp, Ollama, Google, ...). 10+ search engines - arXiv, PubMed, your private documents. Everything Local & Encrypted.

Fix shellcheck warnings in all shell scripts

LearningCircuit309b2a619e75
diff --git a/.github/scripts/file-whitelist-check.sh b/.github/scripts/file-whitelist-check.sh
index 526035f72e..af91aa61b9 100755
--- a/.github/scripts/file-whitelist-check.sh
+++ b/.github/scripts/file-whitelist-check.sh
@@ -624,7 +624,7 @@ esac
if [ -f "$FILE_PATH" ]; then
FILE_SIZE=$(stat -c%s "$FILE_PATH" 2>/dev/null || echo "unknown")
if [ "$FILE_SIZE" != "unknown" ]; then
-READABLE_SIZE=$(echo $FILE_SIZE | awk '{if($1>=1048576) printf "%.1fMB", $1/1048576; else if($1>=1024) printf "%.1fKB", $1/1024; else printf "%dB", $1}')
+READABLE_SIZE=$(echo "$FILE_SIZE" | awk '{if($1>=1048576) printf "%.1fMB", $1/1048576; else if($1>=1024) printf "%.1fKB", $1/1024; else printf "%dB", $1}')
echo " → File size: $READABLE_SIZE"
fi
fi
diff --git a/.pre-commit-hooks/file-whitelist-check.sh b/.pre-commit-hooks/file-whitelist-check.sh
index f8a7d1a55f..54646dc16c 100755
--- a/.pre-commit-hooks/file-whitelist-check.sh
+++ b/.pre-commit-hooks/file-whitelist-check.sh
@@ -79,7 +79,7 @@ for file in "$@"; do
# 2. Large file check (>1MB)
FILE_SIZE=$(stat -c%s "$file" 2>/dev/null || stat -f%z "$file" 2>/dev/null || echo 0)
if [ "$FILE_SIZE" -gt 1048576 ]; then
- LARGE_FILES+=("$file ($(echo $FILE_SIZE | awk '{printf "%.1fMB", $1/1024/1024}'))")
+ LARGE_FILES+=("$file ($(echo "$FILE_SIZE" | awk '{printf "%.1fMB", $1/1024/1024}'))")
fi
done
diff --git a/docs/security/analyze_sarif.sh b/docs/security/analyze_sarif.sh
index a93a1a9793..3d2d652765 100644
--- a/docs/security/analyze_sarif.sh
+++ b/docs/security/analyze_sarif.sh
@@ -95,7 +95,7 @@ if curl -s -X POST "$OLLAMA_ENDPOINT" \
-H "Content-Type: application/json" \
-d "$REQUEST_BODY" | \
while IFS= read -r line; do
- if [ ! -z "$line" ]; then
+ if [ -n "$line" ]; then
echo "$line" | jq -r '.response // empty'
fi
done > "$OUTPUT_PATH"; then
diff --git a/examples/benchmarks/claude_grading/run_benchmark.sh b/examples/benchmarks/claude_grading/run_benchmark.sh
index 8eb1d17245..6b8b1de372 100755
--- a/examples/benchmarks/claude_grading/run_benchmark.sh
+++ b/examples/benchmarks/claude_grading/run_benchmark.sh
@@ -2,13 +2,14 @@
# Run a benchmark with Claude API grading integration
# Navigate to project root which is needed for proper imports
-cd "$(dirname "$0")/../../.."
+cd "$(dirname "$0")/../../.." || exit 1
echo "Changed to project root: $(pwd)"
# Activate virtual environment if it exists
VENV_PATH=".venv/bin/activate"
if [ -f "$VENV_PATH" ]; then
echo "Activating virtual environment..."
+ # shellcheck source=/dev/null
source "$VENV_PATH"
else
echo "Warning: Virtual environment not found at $VENV_PATH"
diff --git a/examples/elasticsearch/test_elasticsearch.sh b/examples/elasticsearch/test_elasticsearch.sh
index acf9378540..f94900ffea 100755
--- a/examples/elasticsearch/test_elasticsearch.sh
+++ b/examples/elasticsearch/test_elasticsearch.sh
@@ -25,7 +25,7 @@ if command -v docker &> /dev/null; then
echo "Waiting for Elasticsearch to be ready (this may take 30-60 seconds)..."
# Wait for Elasticsearch to be ready
- for i in {1..30}; do
+ for _ in {1..30}; do
if curl -s -o /dev/null -w "%{http_code}" http://localhost:9200 | grep -q "200"; then
echo -e "${GREEN}✓ Elasticsearch is ready!${NC}"
break
diff --git a/scripts/dev/restart_server.sh b/scripts/dev/restart_server.sh
index fadbf13ca2..1a24d0d79d 100755
--- a/scripts/dev/restart_server.sh
+++ b/scripts/dev/restart_server.sh
@@ -9,7 +9,7 @@ sleep 1
echo "Starting LDR server..."
# Change to the script's parent directory (project root)
-cd "$(dirname "$0")/../.."
+cd "$(dirname "$0")/../.." || exit 1
# Start server in background and detach from terminal
(nohup pdm run python -m local_deep_research.web.app > /tmp/ldr_server.log 2>&1 &) &
diff --git a/scripts/dev/stop_server.sh b/scripts/dev/stop_server.sh
index 14ef1c2e50..4e7609de3c 100755
--- a/scripts/dev/stop_server.sh
+++ b/scripts/dev/stop_server.sh
@@ -27,7 +27,7 @@ pkill -f "flask run" 2>/dev/null
# Check final status
if pgrep -f "python -m local_deep_research.web.app" > /dev/null; then
echo "Error: Server processes still running:"
- ps aux | grep "python -m local_deep_research.web.app" | grep -v grep
+ pgrep -af "python -m local_deep_research.web.app"
exit 1
else
echo "All server processes stopped"
diff --git a/scripts/ollama_entrypoint.sh b/scripts/ollama_entrypoint.sh
index 344dc4577b..2be1dadc7d 100755
--- a/scripts/ollama_entrypoint.sh
+++ b/scripts/ollama_entrypoint.sh
@@ -27,9 +27,8 @@ echo "Ollama service is ready."
# Pull the model using ollama pull
echo "Pulling the $MODEL_NAME with ollama pull..."
-ollama pull $MODEL_NAME
# Check if the model was pulled successfully
-if [ $? -eq 0 ]; then
+if ollama pull "$MODEL_NAME"; then
echo "Model pulled successfully."
else
echo "Failed to pull model."
@@ -38,4 +37,3 @@ fi
# Run ollama forever.
sleep infinity
-```
diff --git a/tests/health_check/test_endpoints_health.sh b/tests/health_check/test_endpoints_health.sh
index e21cf8b2fb..0bfa61bf30 100755
--- a/tests/health_check/test_endpoints_health.sh
+++ b/tests/health_check/test_endpoints_health.sh
@@ -29,7 +29,7 @@ ENDPOINTS=(
echo -e "${BLUE}🏥 Starting health check for ${#ENDPOINTS[@]} endpoints...${NC}"
echo -e "${BLUE}🌐 Base URL: $BASE_URL${NC}"
-echo "$(printf '=%.0s' {1..60})"
+printf '=%.0s' {1..60}; echo
# Test connectivity first
echo -e "${YELLOW}🔍 Testing connectivity...${NC}"
@@ -42,7 +42,7 @@ else
fi
echo ""
-echo "$(printf '=%.0s' {1..60})"
+printf '=%.0s' {1..60}; echo
# Test each endpoint
success_count=0
@@ -75,7 +75,7 @@ for endpoint in "${ENDPOINTS[@]}"; do
fi
done
-echo "$(printf '=%.0s' {1..60})"
+printf '=%.0s' {1..60}; echo
# Calculate success rate
success_rate=$((success_count * 100 / total_count))
@@ -98,7 +98,7 @@ for endpoint in "${ENDPOINTS[@]}"; do
if [[ "$endpoint" == *"/api/"* || "$endpoint" == "/api/"* ]]; then
((api_count++))
# Check if this endpoint was successful
- if [[ ! " ${failed_endpoints[@]} " =~ " ${endpoint} " ]]; then
+ if [[ ! " ${failed_endpoints[*]} " =~ \ ${endpoint}\ ]]; then
((api_success++))
fi
fi
@@ -110,7 +110,7 @@ if [ $api_count -gt 0 ]; then
fi
echo ""
-if [ $success_count -eq $total_count ]; then
+if [ "$success_count" -eq "$total_count" ]; then
echo -e "${GREEN}🎉 All endpoints are healthy!${NC}"
exit 0
else
diff --git a/tests/run_followup_tests.sh b/tests/run_followup_tests.sh
index 28afb3fbbb..1045f8255d 100755
--- a/tests/run_followup_tests.sh
+++ b/tests/run_followup_tests.sh
@@ -19,13 +19,11 @@ check_server() {
# Start server if not running
if ! check_server; then
echo -e "${YELLOW}Starting local server...${NC}"
- cd src
- nohup python -m local_deep_research.web.app --port 5000 > ../server_test.log 2>&1 &
+ (cd src && nohup python -m local_deep_research.web.app --port 5000 > ../server_test.log 2>&1 &)
SERVER_PID=$!
- cd ..
# Wait for server to start
- for i in {1..30}; do
+ for _ in {1..30}; do
if check_server; then
echo -e "${GREEN}Server started successfully${NC}"
break
@@ -64,7 +62,7 @@ fi
echo ""
echo "🖥️ Running UI Tests..."
echo "---------------------"
-cd tests/ui_tests
+cd tests/ui_tests || exit 1
# Install npm dependencies if needed
if [ ! -d "node_modules" ]; then
@@ -85,7 +83,7 @@ else
fi
# Stop server if we started it
-if [ ! -z "$SERVER_PID" ]; then
+if [ -n "$SERVER_PID" ]; then
echo ""
echo "Stopping test server..."
kill $SERVER_PID 2>/dev/null
diff --git a/tests/test_llm/run_llm_tests.sh b/tests/test_llm/run_llm_tests.sh
index 22bc9b4fa3..67a0a9b9af 100755
--- a/tests/test_llm/run_llm_tests.sh
+++ b/tests/test_llm/run_llm_tests.sh
@@ -5,7 +5,8 @@ echo "Running LLM Integration Tests"
echo "============================="
# Set up environment
-export PYTHONPATH=$PYTHONPATH:$(pwd)
+PYTHONPATH="${PYTHONPATH}:$(pwd)"
+export PYTHONPATH
export LDR_USE_FALLBACK_LLM=true
# Run registry tests
diff --git a/tests/ui_tests/run_api_key_test.sh b/tests/ui_tests/run_api_key_test.sh
index 63311201ad..7f98b026ac 100755
--- a/tests/ui_tests/run_api_key_test.sh
+++ b/tests/ui_tests/run_api_key_test.sh
@@ -40,10 +40,8 @@ echo ""
echo -e "${BLUE}Starting comprehensive API key test...${NC}"
echo "----------------------------------------"
-node test_api_key_comprehensive.js
-
-# Check exit code
-if [ $? -eq 0 ]; then
+# Check exit code directly
+if node test_api_key_comprehensive.js; then
echo ""
echo -e "${GREEN}✓ All tests passed!${NC}"
echo -e "${BLUE}Check screenshots in /tmp/ for visual confirmation${NC}"