busybox/libbb/single_argv.c
Denys Vlasenko 791b222dd5 sleep: fix "sleep -- ARGS"
function                                             old     new   delta
sleep_main                                           116     119      +3
printf_main                                          860     837     -23
single_argv                                           50      25     -25
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/2 up/down: 3/-48)             Total: -45 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2023-10-02 13:56:32 +02:00

25 lines
477 B
C

/* vi: set sw=4 ts=4: */
/*
* Utility routines.
*
* Copyright (C) 2009 Denys Vlasenko
*
* Licensed under GPLv2, see file LICENSE in this source tree.
*/
#include "libbb.h"
char** FAST_FUNC skip_dash_dash(char **argv)
{
argv++;
if (argv[0] && argv[0][0] == '-' && argv[0][1] == '-' && argv[0][2] == '\0')
argv++;
return argv;
}
char* FAST_FUNC single_argv(char **argv)
{
argv = skip_dash_dash(argv);
if (!argv[0] || argv[1])
bb_show_usage();
return argv[0];
}