PeterDaveHello / ColorEchoForShell

Make 🐚(shell) 's 💬 (`echo`) to be 🎨 easily ✨ Support ✅ sh ➕ bash ➕ zsh ➕ ksh ➕ 🐟 One simple command for vibrant text output! 💫
GNU General Public License v2.0
113 stars 18 forks source link

check command `type` is not valid #1

Closed ftwbzhao closed 9 years ago

ftwbzhao commented 9 years ago

原来的逻辑校验lolcat命令不严谨,当命令不存在时,仍然可以执行echo "$@" | lolcat


if [ "type lolcat" ]; then
PeterDaveHello commented 9 years ago

@ftwbzhao Would you leave files under dist alone? I think it will only be regenerated when we bump its version, thanks.

PeterDaveHello commented 9 years ago

And I wonder if most of unix environments give *not found when failed. I think take the exit status code of type lolcat will a better method.

ftwbzhao commented 9 years ago

When use exit status code

    `type lolcat`                                                                                                            
    if [ $? -ne 127 ]; then  
        #here $@ = `type lolcat`                                                                                                         
        echo "$@" | lolcat                                                                            
    else                                                                                                                   
        echo "$@"                                                                                                          
    fi   
ftwbzhao commented 9 years ago

@PeterDaveHello depending on you.

PeterDaveHello commented 9 years ago

@ftwbzhao Would you like to modify this PR to use $? to determinate it?

PeterDaveHello commented 8 years ago

Hi @ftwbzhao, sorry for the late reply and fix, this problem has been fixed in b7bf7e1 and released in v0.0.6, feel free to try! Thanks.