2346

12 分钟

#Bash 的 false 命令

false OPTION

功能

什么也不做,直接返回失败(1),通常用于 if 语句。

类型

Bash 内置命令。

false 也是 coreutils 的一个可执行文件;为了保持 POSIX 标准的兼容性,确保在其他 shell(比如一些极简的或古老的 shell)或者某些特定环境下,命令依然可用。

参数

  • OPTION 选项:
    • --help - 显示帮助
    • --version - 显示版本

#示例

if [ false ]; then echo 吃饭 else echo 睡觉 fi

>>> Establishing WebAssembly Runtime.

>>> Standby.

Powered by Shift.

#相关命令

命令说明
true直接返回失败
test评估表达式的布尔值

#推荐阅读

#手册

FALSE(1) User Commands FALSE(1) NAME false - do nothing, unsuccessfully SYNOPSIS false [ignored command line arguments] false OPTION DESCRIPTION Exit with a status code indicating failure. --help display this help and exit --version output version information and exit NOTE: your shell may have its own version of false, which usually su‐ persedes the version described here. Please refer to your shell's doc‐ umentation 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/false> or available locally via: info '(coreutils) false invocation' GNU coreutils 9.4 April 2024 FALSE(1)

创建于 2025/11/7

更新于 2025/11/7