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

Bug#281735: validlocale: Validity check and error handling could be improved

Package: base-config
Severity: wishlist
Version: 2.58

I see two problems with the current version of validlocales.
(See #281530 and #281538 for the background to this BR.)

- Calling validlocales with a nonexisting locale does not generate
  an error other than '1', which I take to mean "not found, but can
  be generated":
  # /usr/sbin/validlocale qzx
  locale 'qzx' not available
  qzx ISO-8859-1
  # echo $?

  This makes "validlocales" a bit of a misnomer as it does not actually
  check the validity of a locale, but rather if the locale has been
  generated yet.
  As validlocale uses /usr/share/i18n/SUPPORTED, it should be able to
  distinguish between "not generated" and "not supported at all".

- The return codes for a "usage error" is the same as for "not found,
  but can be generated":

  # /usr/sbin/validlocale
  Usage: /usr/sbin/validlocale <locale>
  # echo $?

  # /usr/sbin/validlocale nl_NL@euro
  locale 'nl_NL@euro' not available
  nl_NL@euro ISO-8859-15
  # echo $?

  This makes it difficult to properly test the result in a script.

Note: implementing these changes may necessitate checking scripts that
      currently use validlocale.

Reply to: