From c0a25528e853c5883793cd4edc7908264ca540ab Mon Sep 17 00:00:00 2001 From: Vitaly Chikunov Date: Thu, 18 Apr 2024 04:29:10 +0300 Subject: [PATCH] shebang.req: Allow env with split-string arguments Check for -S/--split-string= options, former could be (out of all other options) prefixed only with `i`. For now, this covers only the simplest cases where the first non-blank word is the command name itself. NB: /usr/bin/env -v is deliberately not supported. Link: https://bugzilla.altlinux.org/50059 Signed-off-by: Vitaly Chikunov --- scripts/shebang.req.in | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/scripts/shebang.req.in b/scripts/shebang.req.in index 73a7854..c1e0003 100755 --- a/scripts/shebang.req.in +++ b/scripts/shebang.req.in @@ -41,6 +41,13 @@ ShebangReq() Warning "$f: trailing in arguments: $line" } + GetEnvCmd() + { + shift + expr match "$*" "-i*S\s*\(\S\+\)" || + expr match "$*" "--split-string=\s*\(\S\+\)" + } + local RPM_FINDPACKAGE_MANDATORY=1 case "$#,$1" in 1,*) @@ -57,7 +64,10 @@ ShebangReq() ;; *,/usr/bin/env) CheckArgs "$*" - Fatal "$f: too many arguments: $line" + local cmd + cmd=$(GetEnvCmd "$@") || + Fatal "$f: too many arguments: $line" + FindPackage "$f" "$cmd" ;; *) CheckArgs "$*"