summaryrefslogtreecommitdiffstats
path: root/misc-utils/whereis.c
Commit message (Collapse)AuthorAgeFilesLines
* whereis: make subdirs scan more robustKarel Zak2019-05-231-10/+27
| | | | | | | | | * 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>
* whereis: use xstrncpy()Karel Zak2019-05-201-4/+2Star
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* misc: consolidate version printing and close_stdout()Karel Zak2019-04-161-7/+5Star
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* docs: fix typos [codespell]Sami Kerola2019-02-181-1/+1
| | | | | Reference: https://github.com/codespell-project/codespell Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* whereis: search in /(s)bin before /usr/libKarel Zak2019-01-171-2/+2
| | | | | Addresses: https://github.com/karelzak/util-linux/issues/741 Signed-off-by: Karel Zak <kzak@redhat.com>
* include/debug: introduce __UL_INIT_DEBUG_FROM_STRING()Karel Zak2018-01-171-1/+1
| | | | | | | 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>
* include/debug: don't print pointer address for SUID programsKarel Zak2018-01-121-0/+3
| | | | | | | | | | | | | | | | * 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>
* whereis: fix typo in debug messageKarel Zak2017-12-141-1/+1
| | | | | Reported-by: Matthew White <mehw.is.me@inventati.org> Signed-off-by: Karel Zak <kzak@redhat.com>
* whereis: include native multiarch path in lib search pathsAndreas Henriksson2017-07-311-0/+5
| | | | | | | | | | | | | | | | | 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>
* misc: consolidate macro style USAGE_HELP_OPTIONSRuediger Meier2017-06-291-2/+2
| | | | | | | | | 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>
* misc: introduce print_usage_help_options()Ruediger Meier2017-06-271-2/+1Star
| | | | | | | | | | | | 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>
* whereis: add --help and --versionRuediger Meier2017-06-221-13/+35
| | | | | | | 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: add static keyword to where needed [smatch scan]Sami Kerola2017-02-201-1/+1
| | | | | | | text-utils/rev.c:68:9: warning: symbol 'buf' was not declared. Should it be static? Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* libblkid/whereis: simplify some conditions [cppcheck]Boris Egorov2015-06-251-1/+1
| | | | | | | | | [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>
* whereis: make "-BMS <dir> -f" more obvious in usage()Karel Zak2015-03-051-1/+1
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* whereis: tell when mandatory option is missingSami Kerola2015-03-031-1/+11
| | | | | | | | | 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>
* whereis: lookup also info docsKarel Zak2015-02-021-3/+4
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* textual: fix various minor typosYuri Chornoivan2015-01-261-1/+1
|
* textual: add a docstring to most of the utilitiesBenno Schulenberg2015-01-061-0/+3
| | | | | | | | | 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>
* include/debug: fix typoKarel Zak2014-10-241-1/+1
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* whereis: reset search mask more carefullyKarel Zak2014-10-231-14/+21
| | | | | | | | | | | | | | | | | | # 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>
* whereis: cleanup debug stuff, fix argv[] usageKarel Zak2014-10-231-33/+74
| | | | | | | | | | | | | | | | | | | | * 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>
* textual: fix some typos and inconsistencies in various messagesBenno Schulenberg2014-07-231-1/+1
| | | | | | | | 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>
* Merge branch 'minor-fixes' of git://github.com/kerolasa/lelux-utiliteetitKarel Zak2014-07-141-2/+1Star
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * '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
| * whereis: avoid printing uninitialized stringSami Kerola2014-07-131-2/+1Star
| | | | | | | | | | | | The patbuf[] needs to be filled before print out. Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* | whereis: fix missing newline on empty resultsAndreas Henriksson2014-07-141-1/+1
|/ | | | | | | | 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>
* whereis: canonicalize directories pathsKarel Zak2013-03-201-5/+6
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* whereis: support MANPATH environment variableSami Kerola2013-03-191-0/+2
| | | | | | | | | | 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>
* whereis: align with howto-usage-function.txtSami Kerola2013-03-191-18/+15Star
| | | | Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* whereis: add search scope listing optionSami Kerola2013-03-191-0/+29
| | | | | | | 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>
* whereis: rewrite most of the commandSami Kerola2013-03-191-263/+310
| | | | | | | | | 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>
* a pointer should not be compared to zero [coccinelle]Sami Kerola2013-02-061-3/+3
| | | | Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* textual: spell and encode the name of Arkadiusz Miƛkiewicz correctlyBenno Schulenberg2013-02-061-1/+1
| | | | Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
* textual: use UTIL_LINUX_VERSION everywhereKarel Zak2013-01-251-3/+1Star
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* textual: fix a few typos in some of the usage help textsBenno Schulenberg2013-01-251-4/+4
| | | | | | Also improve clarity of some other lines of those texts. Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
* whereis: improve readability for analysersKarel Zak2012-09-071-1/+2
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* whereis: fix shadow declarationKarel Zak2012-07-261-4/+4
| | | | | | | | 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>
* misc-utils: verify writing to streams was successfulSami Kerola2012-04-041-0/+2
| | | | Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* misc-utils: fix typosDavidlohr Bueso2012-02-241-1/+1
| | | | Signed-off-by: Davidlohr Bueso <dave@gnu.org>
* whereis: move token assignment into loop syntaxKarel Zak2012-01-301-5/+3Star
| | | | | Reported-by: Davidlohr Bueso <dave@gnu.org> Signed-off-by: Karel Zak <kzak@redhat.com>
* whereis: remove unused value warningFrancesco Cosoleto2011-11-091-1/+1
| | | | Signed-off-by: Francesco Cosoleto <cosoleto@gmail.com>
* whereis: non-ANSI definition [smatch scan]Karel Zak2011-09-121-1/+1
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* whereis: fix gcc warnings [-Wsign-compare]Karel Zak2011-08-311-1/+1
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* whereis: search in path for binaries onlyKarel Zak2011-08-301-7/+8
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* whereis: search in pathDavidlohr Bueso2011-08-301-1/+68
| | | | | | | | | | | 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>
* whereis: cleanup usage()Karel Zak2011-08-161-15/+17
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* whereis: update coding styleDavidlohr Bueso2011-07-261-190/+170Star
| | | | | | | | | 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>
* whereis: remove find()Davidlohr Bueso2011-07-261-11/+3Star
| | | | | | | 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>
* whereis: coding styleSami Kerola2011-06-251-69/+79
| | | | | | Changes only placement of braces, spacing, tabs etc. Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* whereis: warnings, exit values, braces and returnsSami Kerola2011-06-251-12/+12
| | | | | | | | 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>