Command: command & type
command
command 只能跳过function,而不能跳过shell builtin

三个选项 -vV都是打印 -p 使用 default PATH 执行命令

bash默认PATH: /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin

getconf retrieve the values POSIX or system configuration variables
command -p getconf PATH

Reimplement command
function command() { echo 'execute shell builtin `command` with args' "$@" builtin command "$@" }

type


#!/bin/env sh source /etc/rc.d/init.d/functions function pwd(){ action pwd true } echo -e '\e[7;45mDirect run pwd\e[0m' pwd echo -e '\e[5;42mRun command pwd\e[0m' command pwd if command -v pwd &> /dev/null;then action 'pwd exists?' true else action 'pwd exists?' false fi if command -pv pwd >& /dev/null;then action 'System pwd exists?' true else action 'System pwd exists?' false fi

浙公网安备 33010602011771号