- True (Unix)
In
Unix-like operating system s, true is a command whose only function is to always return the value 0, which is regarded by the shell as thelogical value "true". It is usually employed inconditional statement s and loops ofshell script s where Boolean conditions are given as the return value of a program. For example, the followingBourne shell script echos the stringhello
until interrupted:while truedo echo hellodoneThis program takes 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 (inPOSIX -compatible shells such as theBourne shell ) as a dummy command when assigning default values toshell variable s through the${parameter:=word}
parameter expansion form. [ [http://www.opengroup.org/onlinepubs/009695399/utilities/xcu_chap02.html#tag_02_06_02 Shell Command Language: 2.6.2 Parameter Expansion] – The Open Group Base Specifications Issue 6, IEEE Std 1003.1, 2004 Edition] For example, from bashbug, the bug-reporting script forbash : : ${TMPDIR :=/tmp} : ${EDITOR=$DEFEDITOR} : ${USER=${LOGNAME-`whoami`References
ee also
*
false (Unix)
*List of Unix programs External links
*
Wikimedia Foundation. 2010.