Bug 241906 - `locale -k` with an invalid keyword exits with 0
Summary: `locale -k` with an invalid keyword exits with 0
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: bin (show other bugs)
Version: CURRENT
Hardware: Any Any
: --- Affects Some People
Assignee: Yuri Pankov
URL:
Keywords: patch
Depends on:
Blocks:
 
Reported: 2019-11-12 05:37 UTC by AJ Jordan
Modified: 2020-07-26 19:22 UTC (History)
5 users (show)

See Also:
yuripv: mfc-stable12+


Attachments
proposed patch for locale (1.10 KB, patch)
2020-06-12 21:39 UTC, Akos Somfai
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description AJ Jordan 2019-11-12 05:37:45 UTC
If I run, for example, `locale -k nonexistant`, I get a helpful error message: `Unknown keyword: 'nonexistant'`.

However, `locale` in this case still exits with an exit code of 0. It should probably exit with nonzero instead to indicate the failure in finding the keyword.
Comment 1 AJ Jordan 2019-11-12 15:22:49 UTC
An identical bug also exists in NetBSD. See https://gnats.netbsd.org/cgi-bin/query-pr-single.pl?number=54692
Comment 2 Akos Somfai 2020-06-12 21:39:24 UTC
Created attachment 215500 [details]
proposed patch for locale

Providing patch where locale returns with error in case of invalid keyword/category.
Comment 3 commit-hook freebsd_committer freebsd_triage 2020-06-13 08:38:19 UTC
A commit references this bug:

Author: yuripv
Date: Sat Jun 13 08:37:25 UTC 2020
New revision: 362146
URL: https://svnweb.freebsd.org/changeset/base/362146

Log:
  locale: exit 1 if unknown keyword was specified

  PR:		241906
  Submitted by:	Akos Somfai <akos.somfai@gmail.com>

Changes:
  head/usr.bin/locale/locale.c
  head/usr.bin/locale/tests/locale_test.sh
Comment 4 Yuri Pankov freebsd_committer freebsd_triage 2020-06-13 08:39:36 UTC
Committed, thank you!
Comment 5 Mark Linimon freebsd_committer freebsd_triage 2020-07-26 00:06:03 UTC
To committer: does this need an MFC, or can this PR just be closed?
Comment 6 Yuri Pankov freebsd_committer freebsd_triage 2020-07-26 00:09:11 UTC
Will MFC shortly.
Comment 7 commit-hook freebsd_committer freebsd_triage 2020-07-26 19:19:18 UTC
A commit references this bug:

Author: yuripv
Date: Sun Jul 26 19:18:56 UTC 2020
New revision: 363577
URL: https://svnweb.freebsd.org/changeset/base/363577

Log:
  MFC r362146:
  locale: exit 1 if unknown keyword was specified

  PR:		241906
  Submitted by:	Akos Somfai <akos.somfai@gmail.com>

Changes:
_U  stable/12/
  stable/12/usr.bin/locale/locale.c
  stable/12/usr.bin/locale/tests/locale_test.sh