ash: printf builtin with no arguments should not exit

This commit is contained in:
Denis Vlasenko 2008-12-10 11:51:45 +00:00
parent 6a2d0d9b8d
commit 311c19a661

View File

@ -359,8 +359,15 @@ int printf_main(int argc UNUSED_PARAM, char **argv)
* We will mimic coreutils. */ * We will mimic coreutils. */
if (argv[1] && argv[1][0] == '-' && argv[1][1] == '-' && !argv[1][2]) if (argv[1] && argv[1][0] == '-' && argv[1][1] == '-' && !argv[1][2])
argv++; argv++;
if (!argv[1]) if (!argv[1]) {
if (ENABLE_ASH_BUILTIN_PRINTF
&& applet_name[0] != 'p'
) {
bb_error_msg("usage: printf FORMAT [ARGUMENT...]");
return 2; /* bash compat */
}
bb_show_usage(); bb_show_usage();
}
format = argv[1]; format = argv[1];
argv2 = argv + 2; argv2 = argv + 2;