[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Request for enhancement: links to 'true' and 'false'

From: Jeffrey Streifling
Subject: Request for enhancement: links to 'true' and 'false'
Date: Sat, 20 Apr 2013 09:31:54 -0600

I'd like to request a small feature addition to the  'true' and 'false' utilities:  a modification to the install script so that /bin/1 is a hardlink to /bin/true and /bin/0 is a hardlink to /bin/false.  (Symlink would work as well if preferred.)  This additional feature would be used with external scripting interpreters that use 0 and 1 as truth values, such as GNU bc.  The useful idiom would be

if `bc <<< "$VAL1 > $VAL2""`

In my view this would be a clearer idiom than what can be achieved without these links, due to the order that parameter expansion, aliasing, etc, are implemented in the shell.  (You can use test or expr to make an exit code for the shell, or fiddle with parameter expansion, or build an if test into the bc code, but these approaches obfuscate what you're doing.  It would be nice to "alias 0='false'", etc., or fiddle with function definitions, but it doesn't work because of the way the shell does various things.)

POSIX doesn't allow truth values in bc expressions, or shell here-strings for that matter, so this would be yet another GNU extension.

Since, at present, 0 and 1 are not names of utilities or internal commands, you get an error if you try to execute 0 or 1.  Consequently, I anticipate that the addition would be backward compatible.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]