Files
fn_registry/bash/functions/infra/detect_wsl.md
T
egutierrez 94efefc7bf feat: add bash infra installer and diagnostic functions
10 funciones Bash del dominio infra: instaladores de herramientas de desarrollo
(install_go, install_nodejs, install_pnpm, install_python312, install_uv,
install_volta, install_wails), diagnostico del sistema (analyze_disk_space,
detect_wsl, list_listening_ports). Automatizan la configuracion del entorno
de desarrollo en Linux/WSL.
2026-04-12 13:54:21 +02:00

47 lines
1.5 KiB
Markdown

---
name: detect_wsl
kind: function
lang: bash
domain: infra
version: "1.0.0"
purity: impure
signature: "detect_wsl([--check]) -> void"
description: "Detecta si el sistema es WSL (Windows Subsystem for Linux). Con --check retorna solo exit code (0=WSL, 1=no WSL) sin output. Sin argumentos imprime versión WSL, usuario Windows, distribución, hostname, unidades montadas y ruta Windows del directorio actual."
tags: [bash, wsl, windows, detect, integration]
uses_functions: []
uses_types: []
returns: []
returns_optional: false
error_type: "error_go_core"
imports: []
params:
- name: --check
desc: "flag: solo detecta y retorna exit code sin producir output (0=WSL, 1=no WSL)"
output: "sin output con --check; informe del entorno WSL a stdout sin argumentos; exit code 1 si no es WSL"
tested: false
tests: []
test_file_path: ""
file_path: "bash/functions/infra/detect_wsl.sh"
source_repo: "https://gitea-dgg044oo04woo4ggcsws4gk0.organic-machine.com/egutierrez/DevLauncher.git"
source_license: "MIT"
source_file: "scripts/linux/gestion_linux/wsl_host.sh"
---
## Ejemplo
```bash
source bash/functions/infra/detect_wsl.sh
# Verificar si es WSL en scripts (sin output)
if detect_wsl --check; then
echo "Estamos en WSL"
fi
# Mostrar información completa del entorno WSL
detect_wsl
```
## Notas
Usa tres métodos de detección en orden: /proc/version, /proc/sys/kernel/osrelease, y la presencia de /mnt/c + WSLInterop. No incluye las acciones interactivas del script original (abrir PowerShell, CMD, Explorer, VS Code).