Giriş
Açıklaması şöyle
... you can use command -v to check for availability of a command. No need to check its output, command will tell you via its exit status if it succeeded to find the command or not (regardless of whether it's an external command found in $PATH, a builtin or a function)command is a mandatory POSIX utility. The -v option to command used to be optional, but it's not any longer in the latest version of the POSIX specification
Örnek
Şöyle yaparız. "#!/usr/bin/sh -" kullanımının açıklaması burada#!/usr/bin/sh -main() {for mycommand doprintf >&2 '%s\n' "Checking $mycommand"if ! command -v -- "$mycommand" > /dev/null 2>&1; thenprintf >&2 '%s\n' "I think I am missing $mycommand"fidone}main less asdf
Hiç yorum yok:
Yorum Gönder