Consider "s." prefixes for source code files only (even though I do not
know which VCS does that), compression suffixes for manual pages and
strict matching for executables.
Calling "whereis python3" is kind of okay to return python3.8 next to
python3, but python3.8-config is not the same tool as python3.
Signed-off-by: Samanta Navarro <ferivoz@riseup.net>
The whereis implementations of FreeBSD, macOS, NetBSD, and OpenBSD do
not strip suffixes. Although whereis is not a POSIX tool and has no
shared standard, even its manual page indicates that the supplied names
are command names.
Commands do not have a suffix on Linux systems.
Stripping suffixes actually leads to issues with tools like fsck.ext4,
since fsck.ext4 is not the same tool as fsck and definitely not the same
tool as fsck.minix.
Signed-off-by: Samanta Navarro <ferivoz@riseup.net>
The commands diff and diff3 are so distinct that their manual pages
should not be mixed in whereis output.
Theoretically this works for commands and binaries with links to each
other, e.g. gpg and gpg2, but if gpg is version 1 and gpg2 is version 2
then manual pages do not match either.
Also the while loop does not decrement "i" while incrementing "dp". The
effect of this is that the output of whereis depends on manual pages
being compressed or not.
The easiest solution is to not ignore trailing numbers.
Signed-off-by: Samanta Navarro <ferivoz@riseup.net>
Add zst as extension for manual pages. Current version of man-db
supports zst extension out of the box.
Signed-off-by: Samanta Navarro <ferivoz@riseup.net>
* call strchr() only once
* avoid things like strcat(buf, strchr(dir, '*') + 1)
* make it more readable
* improve debug messages
Signed-off-by: Karel Zak <kzak@redhat.com>
Let's make it possible to use debug.h without environment variables.
Suggested-by: J William Piggott <elseifthen@gmx.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
* introduce new flag __UL_DEBUG_FL_NOADDR to suppress pointer address printing
* use __UL_DEBUG_FL_NOADDR when SUID
* move ul_debugobj() to debugobj.h, and require UL_DEBUG_CURRENT_MASK
to provide access to the current mask from ul_debugobj(). It's better
than modify all ul_debugobj() calls and use the global mask as
argument.
* remove never used UL_DEBUG_DEFINE_FLAG
Reported-by: halfdog <me@halfdog.net>
Signed-off-by: Karel Zak <kzak@redhat.com>
This includes atleast the native multiarch path in the paths to search.
(Maybe also other multiarch paths should also be searched? But atleast
this is a first step.)
Before this change (on Debian):
$ whereis libc
libc: /usr/share/man/man7/libc.7.gz
After this change:
$ whereis libc
libc: /usr/lib/x86_64-linux-gnu/libc.so /usr/lib/x86_64-linux-gnu/libc.a /usr/share/man/man7/libc.7.gz
Addresses: https://bugs.debian.org/856968
Signed-off-by: Andreas Henriksson <andreas@fatal.se>
changed in include/c.h and applied via sed:
sed -i 's/fprintf.*\(USAGE_MAN_TAIL.*\)/printf(\1/' $(git ls-files -- "*.c")
sed -i 's/print_usage_help_options\(.*\);/printf(USAGE_HELP_OPTIONS\1);/' $(git ls-files -- "*.c")
Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
Consolidate --help and --version descriptions. We are
now able to align them to the other options.
We changed include/c.h. The rest of this patch was
generated by sed, plus manually setting the right
alignment numbers. We do not change anything but
white spaces in the --help output.
Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
We can use errtryhelp() now and never print usage to stderr.
One may improve all these "bad usage" messages.
Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
[misc-utils/whereis.c:466]: (style) Redundant condition: uflag.
'A && (!A || B)' is equivalent to 'A || B'
[libblkid/src/tag.c:373]: (style) Redundant condition: dev.
'A && (!A || B)' is equivalent to 'A || B'
Signed-off-by: Boris Egorov <egorov@linux.com>
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>
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>
# 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>
* 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>
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>
* '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
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>
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>
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>
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>
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>