From 385a9a17472538cca5e705fda0afb26f8925b901 Mon Sep 17 00:00:00 2001 From: Konstantin Cheremisov Date: Thu, 29 Jan 2026 14:46:15 +0200 Subject: [PATCH] Fix -r option argument order dependency Move state.optind assignment from inside case 'r' to after the getopt loop completes. This ensures optind points to the first positional argument regardless of option order. Before: -r file.amb -w output.wav would fail with "could not open -w" After: argument order no longer matters for -r with other options --- src/dsd_main.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/dsd_main.c b/src/dsd_main.c index 15cd5bd..106f768 100644 --- a/src/dsd_main.c +++ b/src/dsd_main.c @@ -3088,7 +3088,6 @@ opts.dmr_stereo = 0; state.dmr_stereo = 0; sprintf (opts.output_name, "MBE Playback"); - state.optind = optind; break; case 'l': opts.use_cosine_filter = 0; @@ -3098,6 +3097,10 @@ exit (0); } } + + // Set optind after getopt completes so -r works regardless of argument order + if (opts.playfiles == 1) + state.optind = optind; if (opts.resume > 0) {