Commit Graph

48 Commits

Author SHA1 Message Date
Sami Kerola a3d29ee0c7 whereis: tell when mandatory option is missing
The <dirs> list is terminated by any arbitrary option, but to be simple
when none is specified complain about -f being missing.

Reviewed-by: Benno Schulenberg <bensberg@justemail.net>
Reviewed-by: Karel Zak <kzak@redhat.com>
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2015-03-03 19:35:27 +00:00
Karel Zak db0ccb761d whereis: lookup also info docs
Signed-off-by: Karel Zak <kzak@redhat.com>
2015-02-02 11:15:47 +01:00
Yuri Chornoivan 6e834d67ee textual: fix various minor typos 2015-01-26 11:38:38 +01:00
Benno Schulenberg 451dbcfae1 textual: add a docstring to most of the utilities
This adds a concise description of a tool to its usage text.

A first form of this patch was proposed by Steven Honeyman
(see http://www.spinics.net/lists/util-linux-ng/msg09994.html).

Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
2015-01-06 11:27:38 +01:00
Karel Zak 819d9a2975 include/debug: fix typo
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-10-24 11:19:23 +02:00
Karel Zak f4802c9011 whereis: reset search mask more carefully
# whereis -m cal -M /usr/share/man/man1/ -f ls
 cal: /usr/share/man/man1/cal.1.gz /usr/share/man/man1p/cal.1p.gz
 ls: /usr/bin/ls /usr/share/man/man1/ls.1.gz

the -M also resets the search mask, so for 'ls' it returns also
binaries. That's bug. Expected result is:

 # ./whereis -m cal -M /usr/share/man/man1/ -f ls
 cal: /usr/share/man/man1/cal.1.gz /usr/share/man/man1p/cal.1p.gz
 ls: /usr/share/man/man1/ls.1.gz

the search mask has to be sensitive only to -b -m -s options,
otherwise the semantic is pretty messy.

Signed-off-by: Karel Zak <kzak@redhat.com>
2014-10-23 14:29:45 +02:00
Karel Zak 3635f53ca2 whereis: cleanup debug stuff, fix argv[] usage
* use debug stuff from include/debug.h and make whereis(1) sensitive
  to WHEREIS_DEBUG=0xffff mask

* fix problem with argv[] usage

  # whereis -b -m -M /usr/share/man/man1 -B /usr/bin -f gcc
  bin: /usr/local/bin
  gcc: /usr/bin/gcc /usr/lib/gcc /usr/libexec/gcc /usr/share/man/man1/gcc.1.gz

the code ignores "-B" and /usr/bin is interpreted as search pattern,
expected result is:

  # whereis -b -m -M /usr/share/man/man1 -B /usr/bin -f gcc
  gcc: /usr/share/man/man1/gcc.1.gz /usr/bin/gcc

Addresses: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=765306
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-10-23 13:44:00 +02:00
Benno Schulenberg 09af3db48e textual: fix some typos and inconsistencies in various messages
Fixing plain typos, miswordings, inconsistent periods, some missing
angular brackets, and a proper pluralization (even when it involves
a constant, because for some languages the precise value matters).

Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
2014-07-23 08:56:00 +02:00
Karel Zak 2fa32bea49 Merge branch 'minor-fixes' of git://github.com/kerolasa/lelux-utiliteetit
* 'minor-fixes' of git://github.com/kerolasa/lelux-utiliteetit:
  lscpu: avoid double free
  libsmartcols: avoid variable dereference after release
  libfdisk: do not do the same thing twice in single if statement
  whereis: avoid printing uninitialized string
  setpriv: avoid alloca() use xmalloc() instead
  dmesg: avoid unnecessary variable assignment
  fdisk: avoid code duplication
  mkfs.cramfs: use defined failure name rather than magic value
  fdformat: match variable and print format types
  cfdisk: add braces to ensure operation order
  lscpu: avoid use of bzero() in favor of memset()
  setterm: remove unnecessary variable
  cal: remove unnused structure and definition
  textual: fix some typos
2014-07-14 16:03:48 +02:00
Andreas Henriksson 8a11218213 whereis: fix missing newline on empty results
Running "whereis foo.bar.quux" previously resulted in
printing the "foo.bar:" pattern prefix without any
newline following it.

Signed-off-by: Andreas Henriksson <andreas@fatal.se>
2014-07-14 15:49:27 +02:00
Sami Kerola 46ed183613 whereis: avoid printing uninitialized string
The patbuf[] needs to be filled before print out.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2014-07-13 18:35:38 +01:00
Karel Zak f84559ee1c whereis: canonicalize directories paths
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-03-20 11:52:35 +01:00
Sami Kerola ccec32a121 whereis: support MANPATH environment variable
The MANPATH has been around long enough that it can be added to whereis
default search path.

Reference: manpath(1)
Addresses: http://pubs.opengroup.org/onlinepubs/7908799/xbd/envvar.html
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-03-19 16:09:38 +01:00
Sami Kerola ec3bc7aaf4 whereis: align with howto-usage-function.txt
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2013-03-19 16:03:19 +01:00
Sami Kerola 3bfb96365d whereis: add search scope listing option
Mostly useful when debugging why the command does, or does not, work.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-03-19 16:02:32 +01:00
Sami Kerola 9db54a7e08 whereis: rewrite most of the command
The earlier code gave little or no change to fix bugs and improve the
command.  This rewrite attempts to make further patching easier.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Signed-off-by: Karel Zak <kzak@redhat.com>
Co-Author: Karel Zak <kzak@redhat.com>
2013-03-19 15:44:45 +01:00
Sami Kerola f8bd089b1d a pointer should not be compared to zero [coccinelle]
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2013-02-06 11:51:15 +01:00
Benno Schulenberg b50945d4ac textual: spell and encode the name of Arkadiusz Miśkiewicz correctly
Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
2013-02-06 11:15:02 +01:00
Karel Zak e421313dc2 textual: use UTIL_LINUX_VERSION everywhere
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-01-25 12:05:26 +01:00
Benno Schulenberg 095345d07d textual: fix a few typos in some of the usage help texts
Also improve clarity of some other lines of those texts.

Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
2013-01-25 11:47:26 +01:00
Karel Zak 63beec6443 whereis: improve readability for analysers
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-09-07 13:43:49 +02:00
Karel Zak af842d142e whereis: fix shadow declaration
misc-utils/whereis.c:191:7: warning: declaration of 'dirp' shadows a global declaration [-Wshadow]
misc-utils/whereis.c:134:42: warning: shadowed declaration is here [-Wshadow]

Reported-by: Sami Kerola <kerolasa@iki.fi>
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-07-26 13:27:06 +02:00
Sami Kerola c05a80ca63 misc-utils: verify writing to streams was successful
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-04-04 19:56:48 +02:00
Davidlohr Bueso aec5c2a626 misc-utils: fix typos
Signed-off-by: Davidlohr Bueso <dave@gnu.org>
2012-02-24 14:15:39 +01:00
Karel Zak 48a5ed6306 whereis: move token assignment into loop syntax
Reported-by: Davidlohr Bueso <dave@gnu.org>
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-01-30 13:19:14 +01:00
Francesco Cosoleto 3c6e035e1a whereis: remove unused value warning
Signed-off-by: Francesco Cosoleto <cosoleto@gmail.com>
2011-11-09 10:04:24 +01:00
Karel Zak ac9b7477d2 whereis: non-ANSI definition [smatch scan]
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-09-12 16:15:19 +02:00
Karel Zak cc69f339c1 whereis: fix gcc warnings [-Wsign-compare]
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-08-31 11:58:01 +02:00
Karel Zak 4ff826f68a whereis: search in path for binaries only
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-08-30 11:44:15 +02:00
Davidlohr Bueso f51be85982 whereis: search in path
Currently this tool only uses the hardcoded paths for looking up strings for
binaries, man pages and source code.  Adding directories found in $PATH makes a
nice little enhancement to support a wider range of lookups.

This feature was also discussed previously here
(http://www.spinics.net/lists/util-linux-ng/msg03429.html)

Signed-off-by: Davidlohr Bueso <dave@gnu.org>
2011-08-30 11:16:43 +02:00
Karel Zak 5c21c6d23e whereis: cleanup usage()
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-08-16 12:55:26 +02:00
Davidlohr Bueso 0b542a94c4 whereis: update coding style
Like most 20th century Berkeley code, it's horrible:
	- declare global variables in only one place
	- add static attribute where it belongs
	- move funcion declarations so that it doesn't require defining them

Signed-off-by: Davidlohr Bueso <dave@gnu.org>
2011-07-26 11:58:38 +02:00
Davidlohr Bueso 839c025920 whereis: remove find()
Because findv() can do the same job find() does, we can simply remove it and
call findv() with the size of each array.

Signed-off-by: Davidlohr Bueso <dave@gnu.org>
2011-07-26 11:58:38 +02:00
Sami Kerola 30ad62d06f whereis: coding style
Changes only placement of braces, spacing, tabs etc.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2011-06-25 13:29:59 +02:00
Sami Kerola 32ae96aecf whereis: warnings, exit values, braces and returns
Compiler type mismatch warning fixed, symbolic exit value taken
in use where missing, unnecessary single statement 'block' braces
removed and return is not a function bracing fixed.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2011-06-25 13:29:30 +02:00
Sami Kerola 12b806427d whereis: remove goto statements
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2011-06-25 13:29:22 +02:00
Sami Kerola 5851336376 whereis: new usage output & version printing
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2011-06-25 13:20:01 +02:00
Daniel Mierswa c0f19ccff7 replace bcopy,bzero,index and rindex
Those 4 functions are marked as LEGACY in POSIX.1-2001 and removed in
POSIX.1-2008.

Replaced with memmove,memset,strchr and strrchr.

Signed-off-by: Daniel Mierswa <impulze@impulze.org>
2009-08-17 11:15:59 +02:00
maximilian attems 7574f09b3d whereis: include dirent.h instead sys/dir.h
sys/dir.h is an old BSD'ism not carried by klibc,
include dirent directly.

compile tested against glibc.

Signed-off-by: maximilian attems <max@stro.at>
2008-07-28 11:08:30 +02:00
Karel Zak 7dff8582f8 whereis: add lib64 paths
Signed-off-by: Karel Zak <kzak@redhat.com>
2007-07-11 11:15:45 +02:00
Karel Zak c07ebfa1e0 Imported from util-linux-2.11b tarball. 2006-12-07 00:25:46 +01:00
Karel Zak 66ee8158b6 Imported from util-linux-2.10s tarball. 2006-12-07 00:25:44 +01:00
Karel Zak 22853e4a82 Imported from util-linux-2.10m tarball. 2006-12-07 00:25:43 +01:00
Karel Zak 7eda085c41 Imported from util-linux-2.9v tarball. 2006-12-07 00:25:39 +01:00
Karel Zak 5c36a0eb7c Imported from util-linux-2.9i tarball. 2006-12-07 00:25:37 +01:00
Karel Zak 2b6fc908bc Imported from util-linux-2.8 tarball. 2006-12-07 00:25:35 +01:00
Karel Zak fd6b7a7ffc Imported from util-linux-2.7.1 tarball. 2006-12-07 00:25:34 +01:00
Karel Zak 6dbe3af945 Imported from util-linux-2.2 tarball. 2006-12-07 00:25:32 +01:00