Add "exists" to check for command in scripts
This commit is contained in:
		
							parent
							
								
									86f4216cde
								
							
						
					
					
						commit
						0b1b1344d7
					
				
					 1 changed files with 5 additions and 1 deletions
				
			
		|  | @ -22,12 +22,16 @@ succeed() { result $c_success $@ } | ||||||
| error() { echo -n "  "; fail $@ } | error() { echo -n "  "; fail $@ } | ||||||
| warning() { echo -n "  "; warn $@ } | warning() { echo -n "  "; warn $@ } | ||||||
| 
 | 
 | ||||||
|  | exists() { | ||||||
|  | 	type "$1" &>/dev/null | ||||||
|  | } | ||||||
|  | 
 | ||||||
| depend() { | depend() { | ||||||
| 	local missing | 	local missing | ||||||
| 	local i | 	local i | ||||||
| 
 | 
 | ||||||
| 	for i in "$@"; do | 	for i in "$@"; do | ||||||
| 		type "$i" &>/dev/null || { | 		exists "$i" || { | ||||||
| 			echo >&2 " $c_fail Missing dependency: $i. Please install it" | 			echo >&2 " $c_fail Missing dependency: $i. Please install it" | ||||||
| 			missing=1 | 			missing=1 | ||||||
| 		} | 		} | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Alexander Gehrke
						Alexander Gehrke