Implement floating point sleep command ##shell

This commit is contained in:
pancake 2021-08-25 15:44:33 +02:00
parent 13f99e358a
commit 8b23751180

View File

@ -70,7 +70,7 @@ static const char *help_msg_sl[] = {
"sl", "[+-][line]", "Seek to relative line",
"slc", "", "Clear line cache",
"sll", "", "Show total number of lines",
"sleep", " [seconds]", "Sleep for an specific amount of time",
"sleep", " [seconds]", "Sleep for an specific amount of time (support decimal values)",
NULL
};
@ -774,8 +774,15 @@ static int cmd_seek(void *data, const char *input) {
{
const char *arg = strchr (input, ' ');
if (arg) {
arg++;
void *bed = r_cons_sleep_begin ();
r_sys_sleep (atoi (arg + 1));
if (strchr (arg, '.')) {
double d = 0;
sscanf (arg, "%lf", &d);
r_sys_usleep ((int)(d * 1000000));
} else {
r_sys_sleep (atoi (arg));
}
r_cons_sleep_end (bed);
} else {
eprintf ("Usage: sleep [seconds]\n");