johncming / go-spec

my wiki
Apache License 2.0
0 stars 0 forks source link

shell中的command #77

Closed johncming closed 5 years ago

johncming commented 5 years ago

example

 16 toggle_failpoints() {                                                                
 17     mode="$1"                                                                        
 18     if command -v gofail >/dev/null 2>&1; then                                       
 19         gofail "$mode" etcdserver/ mvcc/backend/                                     
 20     elif [[ "$mode" != "disable" ]]; then                                            
 21         echo "FAILPOINTS set but gofail not found"                                   
 22         exit 1                                                                       
 23     fi                                                                               
 24 }  
johncming commented 5 years ago

command command [-pVv] command [arguments …] Runs command with arguments ignoring any shell function named command. Only shell builtin commands or commands found by searching the PATH are executed. If there is a shell function named ls, running ‘command ls’ within the function will execute the external command ls instead of calling the function recursively. The -p option means to use a default value for PATH that is guaranteed to find all of the standard utilities. The return status in this case is 127 if command cannot be found or an error occurred, and the exit status of command otherwise.

If either the -V or -v option is supplied, a description of command is printed. The -v option causes a single word indicating the command or file name used to invoke command to be displayed; the -V option produces a more verbose description. In this case, the return status is zero if command is found, and non-zero if not.

johncming commented 5 years ago

Only shell builtin commands or commands found by searching the PATH are executed.