25 lines
		
	
	
		
			564 B
		
	
	
	
		
			Bash
		
	
	
		
			Executable File
		
	
	
	
	
			
		
		
	
	
			25 lines
		
	
	
		
			564 B
		
	
	
	
		
			Bash
		
	
	
		
			Executable File
		
	
	
	
	
| #!/usr/bin/env bash
 | |
| [ -f functions.sh ] && source functions.sh
 | |
| 
 | |
| # Dependencies required by this module
 | |
| dependencies=("units")
 | |
| 
 | |
| shift
 | |
| chan="$1"
 | |
| shift
 | |
| 
 | |
| # Check dependencies before running
 | |
| if ! check_dependencies "${dependencies[@]}"; then
 | |
|     msg "$chan" "$1: This module requires: ${dependencies[*]}"
 | |
|     exit 1
 | |
| fi
 | |
| 
 | |
| # Validate input
 | |
| if [[ -z "$*" ]]; then
 | |
|     msg "$chan" "Please provide a unit conversion (e.g., '10 meters to feet')."
 | |
|     exit 0
 | |
| fi
 | |
| 
 | |
| # Quote variables to prevent command injection
 | |
| msg "$chan" "$(units -v "${*#* }" | head -n1 | tr -d '[:space:]')"
 |