For portabiliy, check for program_invocation_name during configure and
define HAVE_PROGRAM_INVOCATION_NAME accordingly. Use of this symbol is
now enclosed with the appropriate #ifdef block.
The symbol program_invocation_name is only used for error message
handling using error(), so it's safe to omit this if it is not
available.
watch.c:255:14: warning: no previous declaration for 'get_time_usec' [-Wmissing-declarations]
watch.c:303:6: warning: no previous declaration for 'output_header' [-Wmissing-declarations]
watch.c:364:5: warning: no previous declaration for 'run_command' [-Wmissing-declarations]
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
The commit 8967f0fca3 has an typo like
error, which I must have done. The Bug-Debian 240989 did not have 12
but 128. Rest of the fixes are from Bug-Debian 675069 e.g. missing
include added, and usage of iswprint().
Bug-Debian: http://bugs.debian.org/240989
Bug-Debian: http://bugs.debian.org/675069
Reported-by: "Dr. David Alan Gilbert" <dave@treblig.org>
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
If stream status is not checked at the end of execution below problem
would not report error, or non-zero exit code. The uptime is just an
example same was true with all commands of the project.
$ uptime >&- ; echo $?
uptime: write error: Bad file descriptor
1
$ uptime >/dev/full ; echo $?
uptime: write error: No space left on device
1
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
The main() was starting to be quite long with deep indents. Both
signs of clean up being welcome change.
FIXME: The comment also changes -g option to exit immediately,
when screen contents change. This should be separated commit,
e.g. the stuff is not ready to be merged.
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
When invoked with the --chgexit/-g options wait until we have at
least one screen of output before checking if the output changed.
Otherwise, we're comparing the initial screen of output to all
spaces, which usually isn't what we want.
Revert commit ffe5e0b08e. Restores
clean exit when falling through main loop.
Previously, watch only exited when there was an error or when
interrupted by the user. Commit 81f64657ba
added another exit condition when the watched command's output
changes, causing execution to fall out of the main loop.
With this change, watch correctly restores the terminal and returns
an exit code indicating success when invoked with the --chgexit/-g
options.
The -d, --differences switch(s) can use optional argument that was
not documented earlier.
Reported-By: Marian Sigler <m@qjym.de>
Bug-Debian: http://bugs.debian.org/597021
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Add new flags to watch (-g/--chgexit) so that it exits when the
output changes. This is useful in builds and shell scripts, for
example when deploying webapps to block the remainder of the
deployment steps until after the webapp starts.
e.g. watch --chgexit curl http://foo/bar
Fixes build warning:
watch.c:682:3: warning: implicit declaration of
function 'waitpid' [-Wimplicit-function-declaration]
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
Strings with lower caps & no trailing dots have greater change to
have multiple occurences, meaning less effort for translators, than
strings with them.
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
This change allows user to see what was the last message before exit
on error, and when where the last update.
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
The -e option would print a confusing error message. This is because
most error messages in watch are one word. This fix makes a more
sensible message about what went wrong.
The -x option exited before the endwin() function was called, so if the
child process died the terminal was left in a funky state. endwin is now
called just before the exit(8) for the -x option.
err and warn are BSD format but they are not recommended by library
developers. However their consiseness is useful!
The solution is to use some macros that create xerr etc which then
just map to the error() function. The next problem is error() uses
program_invocation_name so we set this to program_invovation_short_name
This is a global set but seems to be the convention (or at least errors
are on the short name only) used everywhere else.
Add the following three functions to most of the commands.
setlocale (LC_ALL, "");
bindtextdomain(PACKAGE, LOCALEDIR);
textdomain(PACKAGE);
Reference: http://www.freelists.org/post/procps/backporting,1
Reported-by: Jim Warner <james.warner@comcast.net>
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
A patch from Debian.
Bug-Debian: http://bugs.debian.org/183486
Reviewed-by: Craig Small <csmall@debian.org>
Backported-by: Sami Kerola <kerolasa@iki.fi>
Print same style version string as other procps utilities. Also
the number makes now more sense, when it's coming from autotools
config.h
Signed-off-by: Sami Kerola <kerolasa@iki.fi>