The Full Wiki

More info on False (Unix)

False (Unix): Wikis

Advertisements

Note: Many of our articles have direct quotes from sources you can cite, within the Wikipedia article! This article doesn't yet, but we're working on it! See more info or our list of citable articles.

Encyclopedia

(Redirected to true and false (Unix) article)

From Wikipedia, the free encyclopedia

In Unix-like operating systems, true and false are commands whose only function is to always return the value 0 or 1.

Contents

Overview

The shell regards 0 as the logical value true and 1 as false. It is usually employed in conditional statements and loops of shell scripts where Boolean conditions are given as the return value of a program. For example, the following Bourne shell script echos the string hello until interrupted:

while true
do
  echo hello
done

It can be used to make a sequence of otherwise useful commands fail, as in the example:

make … && false

Setting a user's login shell to false, in /etc/passwd, effectively denies them access to an interactive shell, but their account may still be valid for other services, such as FTP.

The programs take no "actual" parameters; in some versions, the standard parameter --help displays a usage summary and --version displays the program version.

true may also be written as a single colon (:). In that form, it is generally built into the shell, and may therefore be more efficient. In its alias of :, true is often used (in POSIX-compatible shells such as the Bourne shell) as a dummy command when assigning default values to shell variables through the ${parameter:=word} parameter expansion form.[1] For example, from bashbug, the bug-reporting script for bash:

: ${TMPDIR:=/tmp}
: ${EDITOR=$DEFEDITOR}
: ${USER=${LOGNAME-`whoami`}}

See also

References

  1. ^ Shell Command Language: 2.6.2 Parameter Expansion – The Open Group Base Specifications Issue 6, IEEE Std 1003.1, 2004 Edition

External links

Advertisements

Manual pages


Template:Lowercase In Unix-like operating systems, false is the command that always returns the value 1, which is regarded by the shell as the logical value false.

This program takes no parameters.

It can be used to make a sequence of otherwise useful commands fail, as in the example:

make … && false

Setting a user's login shell to false, in /etc/passwd, effectively denies them access to an interactive shell, but their account may still be valid for other services, such as FTP.

Contents

See also

References

External links

  • false: return false value – Commands & Utilities Reference, The Single UNIX® Specification, Issue 7 from The Open Group

Manual pages

  • false(1): Do nothing, unsuccessfully – GNU Coreutils reference
  • [[[:Template:Man/default]] false(Template:Man/default)]: Do nothing, unsuccessfully – Template:Man/default

Advertisements






Got something to say? Make a comment.
Your name
Your email address
Message