LINUX.ORG.RU

История изменений

Исправление beastie, (текущая версия) :

Всё ещё широко используется в OpenBSD rc.

Post by Jet Nul
|| Potentially unset variables
|| Remember that variables may not be set, or may be set to the null
|| string. For instance, you may be tempted to write
||
|| if [ $answer = yes ]; then
||
|| However, $answer might be set to the empty string, so sh would see
|| if [ = yes ]; then, which would cause an error. Better to write
||
|| if [ «$answer» = yes ]; then
||
|| The danger here is that $answer might be set to -f, so sh would see
|| if [ -f = yes ]; then, which would also cause an error.
||
|| Therefore, write
||
|| if [ x"$answer" = xyes ]; then
||
|| which avoids both of these problems.

This is a bug in very old sh implementations, but not in pdksh as
is included with OpenBSD.

[ «$answer» = yes ]

Will work fine with ksh. But the OpenBSD teams wants to maintain
portability with older shells, just incase someone decides he
wants to install such an old shell.

ref: http://misc.openbsd.narkive.com/sLcffPRy/test-usage-in-openbsd-shell-scripts

Исправление beastie, :

Всё ещё широко используется в OpenBSD rc.

Post by Jet Nul
|| Potentially unset variables
|| Remember that variables may not be set, or may be set to the null
|| string. For instance, you may be tempted to write
||
|| if [ $answer = yes ]; then
||
|| However, $answer might be set to the empty string, so sh would see
|| if [ = yes ]; then, which would cause an error. Better to write
||
|| if [ «$answer» = yes ]; then
||
|| The danger here is that $answer might be set to -f, so sh would see
|| if [ -f = yes ]; then, which would also cause an error.
||
|| Therefore, write
||
|| if [ x"$answer" = xyes ]; then
||
|| which avoids both of these problems.

This is a bug in very old sh implementations, but not in pdksh as
is included with OpenBSD.

[ «$answer» = yes ]

Will work fine with ksh. But the OpenBSD teams wants to maintain
portability with older shells, just incase someone decides he
wants to install such an old shell.

Исходная версия beastie, :

Всё ещё широко используется в OpenBSD rc.

This is a bug in very old sh implementations, but not in pdksh as is included with OpenBSD.

[ «$answer» = yes ]

Will work fine with ksh. But the OpenBSD teams wants to maintain portability with older shells, just incase someone decides he wants to install such an old shell.

ref: http://misc.openbsd.narkive.com/sLcffPRy/test-usage-in-openbsd-shell-scripts