#Bash 的 true 命令
true OPTION
功能
什么也不做,直接返回成功(0),通常用于 if 语句。
类型
Bash 内置命令。
true也是 coreutils 的一个可执行文件;为了保持 POSIX 标准的兼容性,确保在其他 shell(比如一些极简的或古老的 shell)或者某些特定环境下,命令依然可用。
参数
OPTION选项:--help- 显示帮助--version- 显示版本
#示例
if [ true ]; then
echo 吃饭
else
echo 睡觉
fi
#相关命令
#推荐阅读
#手册
TRUE(1) User Commands TRUE(1) NAME true - do nothing, successfully SYNOPSIS true [ignored command line arguments] true OPTION DESCRIPTION Exit with a status code indicating success. --help display this help and exit --version output version information and exit NOTE: your shell may have its own version of true, which usually super‐ sedes the version described here. Please refer to your shell's docu‐ mentation for details about the options it supports. AUTHOR Written by Jim Meyering. REPORTING BUGS GNU coreutils online help: <https://www.gnu.org/software/coreutils/> Report any translation bugs to <https://translationproject.org/team/> COPYRIGHT Copyright © 2023 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later <https://gnu.org/licenses/gpl.html>. This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. SEE ALSO Full documentation <https://www.gnu.org/software/coreutils/true> or available locally via: info '(coreutils) true invocation' GNU coreutils 9.4 April 2024 TRUE(1)