diff options
author | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2017-09-21 18:01:34 +0200 |
---|---|---|
committer | Dee'Kej <deekej@linuxmail.org> | 2017-09-25 14:56:02 +0200 |
commit | fc9eb02ecb6e2b435f01b682e3b72011db1c1ba6 (patch) | |
tree | e56712a6dc9a54557e6ad1b27abc2a154f06af10 /src | |
parent | 57ea41a213ce6f5b1fd99d38d606e4e0706f8d82 (diff) | |
download | initscripts-fc9eb02ecb6e2b435f01b682e3b72011db1c1ba6.tar initscripts-fc9eb02ecb6e2b435f01b682e3b72011db1c1ba6.tar.gz initscripts-fc9eb02ecb6e2b435f01b682e3b72011db1c1ba6.tar.bz2 initscripts-fc9eb02ecb6e2b435f01b682e3b72011db1c1ba6.tar.xz initscripts-fc9eb02ecb6e2b435f01b682e3b72011db1c1ba6.zip |
usleep: change the error message to print the full replacement commandline
Also drop the argv[0] as previx — the message already includes the
name of the program.
$ src/usleep 1
warning: usleep is deprecated, and will be removed in near future!
warning: use "sleep 1e-06" instead...
$ src/usleep 10
warning: usleep is deprecated, and will be removed in near future!
warning: use "sleep 1e-05" instead...
$ src/usleep 20
warning: usleep is deprecated, and will be removed in near future!
warning: use "sleep 2e-05" instead...
$ src/usleep 100
warning: usleep is deprecated, and will be removed in near future!
warning: use "sleep 0.0001" instead...
$ src/usleep 200
warning: usleep is deprecated, and will be removed in near future!
warning: use "sleep 0.0002" instead...
$ src/usleep 300
warning: usleep is deprecated, and will be removed in near future!
warning: use "sleep 0.0003" instead...
$ src/usleep 400
warning: usleep is deprecated, and will be removed in near future!
warning: use "sleep 0.0004" instead...
$ src/usleep 1000
warning: usleep is deprecated, and will be removed in near future!
warning: use "sleep 0.001" instead...
$ src/usleep 10000
warning: usleep is deprecated, and will be removed in near future!
warning: use "sleep 0.01" instead...
$ src/usleep 100000
warning: usleep is deprecated, and will be removed in near future!
warning: use "sleep 0.1" instead...
$ src/usleep 1000000
warning: usleep is deprecated, and will be removed in near future!
warning: use "sleep 1" instead...
$ src/usleep 10000000
warning: usleep is deprecated, and will be removed in near future!
warning: use "sleep 10" instead...
For very small and very large values, printf uses scientific notation,
but that seems nicer than using %.f which would always leave trailing
zeroes. sleep accepts scientific notation, so things should still work.
https://bugzilla.redhat.com/show_bug.cgi?id=1494168
Diffstat (limited to 'src')
-rw-r--r-- | src/usleep.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/src/usleep.c b/src/usleep.c index d5dfe21b..e5e3077d 100644 --- a/src/usleep.c +++ b/src/usleep.c @@ -44,9 +44,6 @@ int main(int argc, char **argv) { { 0, 0, 0, 0, 0 } }; - fprintf(stderr, "%s: warning: usleep(1) is deprecated, and will be removed in near future!!\n" - "%s: warning: use sleep(1) instead...\n", argv[0], argv[0]); - optCon = poptGetContext("usleep", argc, argv, options,0); /*poptReadDefaultConfig(optCon, 1);*/ poptSetOtherOptionHelp(optCon, "[microseconds]"); @@ -80,6 +77,9 @@ int main(int argc, char **argv) { else count = strtoul(countStr, NULL, 0); + fprintf(stderr, "warning: usleep is deprecated, and will be removed in near future!\n" + "warning: use \"sleep %.7g\" instead...\n", count / 1e6); + usleep(count); return 0; } |