]> git.ipfire.org Git - thirdparty/util-linux.git/commit
script: fix backward compatibility for options after non-option args
authorKarel Zak <kzak@redhat.com>
Tue, 7 Apr 2026 13:20:04 +0000 (15:20 +0200)
committerKarel Zak <kzak@redhat.com>
Tue, 7 Apr 2026 15:00:52 +0000 (17:00 +0200)
commit70507ab9eaed10b8dd77b77d4ea25c11ee726bed
tree500bd816cdfd09d714fd75a9523acdfc4a439147
parent52c48ac89f35de5a41be4dd0e0846fb3e838f7f2
script: fix backward compatibility for options after non-option args

The commit 7268e79b added "+" to the getopt_long() options string to
support the "--" separator for specifying commands. The "+" prefix
makes getopt stop processing at the first non-option argument, which
breaks the traditional "script file -c command" usage.

Fix this by pre-scanning argv for "--" before getopt, separating the
command arguments, and removing the "+" prefix to restore GNU getopt
argument permutation.

Addresses: 7268e79bc5365034a6e5b38ac5d9bf635e2dafc2
Reported-by: Chris Hofstaedtler <zeha@debian.org>
Signed-off-by: Karel Zak <kzak@redhat.com>
term-utils/script.c