trim() {
printf '%s' "$*"
}
...
read shebang_line < "$f" || :
orig_shebang=$(trim $(echo "$shebang_line" | grep -Po "#!\K.*" || echo))
The "trimming", i.e. replacement of multiple spaces and removal of leading
and trailing spaces, is achieved because "trim $(cmd)" construct has an
unquoted $(), which is subject to word splitting.
This works, yes. BUT.
It is also subject to glob expansion - any ?s and *s will be attempted
to be expanded as well - definitely NOT what we want!
This change replaces this trick with code which avoids the expansion issue,
and which does not spawn any subprocesses for string manipulations -
this is ~3 times faster (fork+execs are expensive).
Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
This patch adds two additional rpm macros, __brp_mangle_shebangs_exclude_file
and __brp_mangle_shebangs_exclude_from_file, to specify files from which
to read the extended regexps used for excluding shebangs and target
files.
Additionally, this adds documentation in the macros file and
--help/--usage/-?/-h to brp-mangle-shebangs, so that it's possible to
actually discover what the intended behavior is without reading the
script itself.
Signed-off-by: Peter Jones <pjones@redhat.com>
Now it starts requiring bash instead of POSIX-compatible shell, but this
is not a problem since other scripts in here do same.
Signed-off-by: Igor Gnatenko <ignatenkobrain@fedoraproject.org>
Introduces __brp_mangle_shebangs_exclude_from and __brp_mangle_shebangs_exclude
* the first allows to explude specific paths from the mangling
* the second allows to exlude specific shebangs
Both are used with `grep -E`. Similar escaping rules as in [1] apply.
[1] https://fedoraproject.org/wiki/Packaging:AutoProvidesAndRequiresFiltering