Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

My alterntives to a couple of these:

    function debug()
    {
         if [ -v VERBOSE ]
         then
           echo "${1}" # might want to add:  >2
         fi
    }

    function has_dep()
    {
       unset dependency
       dependency=$(command -v "${1}")
       if [ -v dependency ]
       then
         debug "found \"${1}\": ${dependency}"
         return 0
       else
         debug "\"${1}\": not found"
         return 1
       fi
    }

    # example:
    VERBOSE=1
    if has_dep curl
    then
       echo "we're good"
    fi
    if has_dep notfoundthing
    then
       echo "not good." 
    fi


Consider applying for YC's Winter 2027 batch! Applications are open till November 2.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: