diff --git a/src/builtins/printf.cpp b/src/builtins/printf.cpp index d1a7f17ae..ec4c1c6fd 100644 --- a/src/builtins/printf.cpp +++ b/src/builtins/printf.cpp @@ -649,19 +649,10 @@ int builtin_printf_state_t::print_formatted(const wchar_t *format, int argc, con maybe_t builtin_printf(parser_t &parser, io_streams_t &streams, const wchar_t **argv) { const wchar_t *cmd = argv[0]; int argc = builtin_count_args(argv); - help_only_cmd_opts_t opts; - int optind; - int retval = parse_help_only_cmd_opts(opts, &optind, argc, argv, parser, streams); - if (retval != STATUS_CMD_OK) return retval; + argv++; + argc--; - if (opts.print_help) { - builtin_print_help(parser, streams, cmd); - return STATUS_CMD_OK; - } - - argc -= optind; - argv += optind; if (argc < 1) { return STATUS_INVALID_ARGS; } diff --git a/tests/checks/printf.fish b/tests/checks/printf.fish index 6b7d52795..cecbbaa12 100644 --- a/tests/checks/printf.fish +++ b/tests/checks/printf.fish @@ -119,3 +119,18 @@ printf '%d\n' 0g # CHECKERR: 0g: value not completely converted (can't convert 'g') echo $status # CHECK: 1 + +# Test that we ignore options +printf -a +printf --foo +# CHECK: -a--foo +echo + +set -l helpvar --help +printf $helpvar +echo +# CHECK: --help + +printf --help +echo +# CHECK: --help