Skip to content

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
sh/bat hybrid that checks available commands. Despite its hackish look, it was tested under Windows XP, wine, ksh, zsh, dash and bash.
: ::\
@echo off
rem () ( command -v $1 >/dev/null 2>&1; return $? )
rem : "Usage sh: $ sh exists.cmd ls && echo exists "
rem : "Usage bat: > exists.cmd notepad "
rem : " > echo %ErrorLevel% "
rem $1 <<REM
:exists
if exist %1 exit /b 0
for %%P in ("%PATH:;=" "%") do (
if exist %%~P\%1 ( exit /b 0 )
call :exists_ext %%~P\%1
if not errorlevel 1 ( exit /b 0 )
)
exit /b 1
:exists_ext
for %%P in ("%PATHEXT:;=" "%") do (
if exist %1%%~P ( exit /b 0 )
)
exit /b 1
REM
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.