summaryrefslogtreecommitdiff
path: root/libbb
diff options
context:
space:
mode:
authorDenys Vlasenko2023-10-02 13:56:32 +0200
committerDenys Vlasenko2023-10-02 13:56:32 +0200
commit791b222dd55d3aa0e8b09be1be571e4829465dd6 (patch)
tree64af8d2c7a5787055bacb15c8a9f20ed51c2732f /libbb
parent2cc9d436e80632157b99e18d413a62b2d44d321a (diff)
downloadbusybox-791b222dd55d3aa0e8b09be1be571e4829465dd6.zip
busybox-791b222dd55d3aa0e8b09be1be571e4829465dd6.tar.gz
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>
Diffstat (limited to 'libbb')
-rw-r--r--libbb/single_argv.c15
1 files changed, 11 insertions, 4 deletions
diff --git a/libbb/single_argv.c b/libbb/single_argv.c
index 64844dd..594cb0d 100644
--- a/libbb/single_argv.c
+++ b/libbb/single_argv.c
@@ -8,11 +8,18 @@
*/
#include "libbb.h"
-char* FAST_FUNC single_argv(char **argv)
+char** FAST_FUNC skip_dash_dash(char **argv)
{
- if (argv[1] && strcmp(argv[1], "--") == 0)
+ argv++;
+ if (argv[0] && argv[0][0] == '-' && argv[0][1] == '-' && argv[0][2] == '\0')
argv++;
- if (!argv[1] || argv[2])
+ return argv;
+}
+
+char* FAST_FUNC single_argv(char **argv)
+{
+ argv = skip_dash_dash(argv);
+ if (!argv[0] || argv[1])
bb_show_usage();
- return argv[1];
+ return argv[0];
}