Files
fn_registry/bash/functions/shell/find_free_port.sh
T
egutierrez bf1efb2099 feat: externalize apps/analysis to Gitea repos, add analysis table
- Migration 007: repo_url on apps table + analysis table with FTS5
- Analysis struct, parser, CRUD, validation, hash computation
- Selective purge: remote-only apps/analysis preserved across fn index
- CLI: fn app list/clone/pull, fn analysis list/clone/pull
- search/show/list now include analysis results
- Apps removed from git tracking (content lives in Gitea repos)
- .gitkeep for apps/ and analysis/ dirs
- Bash functions: jupyter analysis pipeline, shell utilities
- Browser domain: CDP functions moved from infra to browser

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-01 04:23:51 +02:00

26 lines
658 B
Bash

# find_free_port
# ---------------
# Busca el primer puerto libre en un rango dado.
# Imprime el puerto encontrado a stdout.
# Sale con exit code 1 si no encuentra ninguno.
#
# USO (sourced):
# source find_free_port.sh
# port=$(find_free_port 8888 8899)
find_free_port() {
local start="${1:-8888}"
local end="${2:-8899}"
for ((port=start; port<=end; port++)); do
if ! ss -tln 2>/dev/null | grep -q ":${port} " && \
! lsof -i:"$port" >/dev/null 2>&1; then
echo "$port"
return 0
fi
done
echo "find_free_port: no se encontro puerto libre en rango ${start}-${end}" >&2
return 1
}