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

Bug#785085: mksh: Misleading note in manpage about equality test



Package: mksh
Version: 50d-5
Severity: minor

Dear Maintainer,

here is a note in manpage about [ $foo = bar ] equality test:

$ MANWIDTH=78 LC_ALL=C man mksh 2>>/dev/null <&2 | grep -A5 'A common mistake is to use'

Note: A common mistake is to use ``if [ $foo = bar ]'' which
fails if parameter ``foo'' is NULL or unset, if it has embedded
spaces (i.e. IFS octets), or if it is a unary operator like '!'
or '-n'.  Use tests like ``if [ x"$foo" = x"bar" ]'' instead, or
the double-bracket operator ``if [[ $foo = bar ]]'' or, to avoid
pattern matching (see [[ above): ``if [[ $foo = "$bar" ]]''

the proposed [ x"$foo" = x"bar" ] is correct but with redundant x character;
this x looks odd and attracts attention, while proper quotation is the point

in order to make it clear it should be something like [ "$foo" = bar ]

-- System Information:
Debian Release: stretch/sid
  APT prefers unstable
  APT policy: (500, 'unstable'), (500, 'testing'), (500, 'stable'), (1, 'experimental')
Architecture: armhf (armv7l)
Foreign Architectures: armel

Kernel: Linux 3.0.35-ygrex-fx6-6.3+ (SMP w/4 CPU cores)
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash
Init: systemd (via /run/systemd/system)

Versions of packages mksh depends on:
ii  libc6  2.19-18

mksh recommends no packages.

Versions of packages mksh suggests:
ii  ed  1.10-2

-- no debconf information


Reply to: