55 lines
1.4 KiB
Bash
Executable File
55 lines
1.4 KiB
Bash
Executable File
#!/bin/sh
|
|
|
|
# Copyright (C) 2017 Red Hat, Inc.
|
|
#
|
|
# This program is free software: you can redistribute it and/or modify
|
|
# it under the terms of the GNU General Public License as published by
|
|
# the Free Software Foundation, either version 3 of the License, or
|
|
# (at your option) any later version.
|
|
#
|
|
# This program is distributed in the hope that it will be useful,
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
# GNU General Public License for more details.
|
|
#
|
|
# You should have received a copy of the GNU General Public License
|
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
# print deprecation warning
|
|
warn()
|
|
{
|
|
echo "$0: warning: usleep(1) is deprecated, use sleep(1) instead!" >&2
|
|
}
|
|
|
|
# simplified option handling
|
|
for arg; do
|
|
case $arg in
|
|
-v|--version)
|
|
warn
|
|
sleep --version
|
|
exit 0
|
|
;;
|
|
-o|--oot|-\?|--help)
|
|
warn
|
|
exit 0
|
|
;;
|
|
-*)
|
|
warn
|
|
echo "$0: bad argument: $arg" >&2
|
|
exit 1
|
|
;;
|
|
esac
|
|
done
|
|
|
|
# check that there is at most one argument
|
|
if [ $# -ge 2 ]; then
|
|
warn
|
|
echo "$0: too many arguments: $#" >&2
|
|
fi
|
|
|
|
# convert microseconds to seconds using bc(1)
|
|
secs="$(printf '%s\n' scale=9 "${1:-1}/1000000" | bc;)"
|
|
|
|
# use sleep(1) as the actual implementation
|
|
exec sleep "$secs"
|