aboutsummaryrefslogtreecommitdiffstats
path: root/brp-mangle-shebangs
Commit message (Collapse)AuthorAgeFilesLines
* brp-mangle-shebangs: Strip env flags when mangling shebangsMiro Hrončok2024-03-241-4/+4
| | | | | | | - For example, mangle "#!/usr/bin/env -S vd" to "#!/usr/bin/vd" - Fixes: rhbz#2265038 Signed-off-by: Jani Välimaa <wally@mageia.org>
* Mangle script shebangsJani Välimaa2023-11-221-1/+1
|
* brp-mangle-shebangs: also mangle shebangs of JavaScript executables ↵Jani Välimaa2023-01-151-1/+1
| | | | (rhbz#1998924)
* Fix handling of files without newlines in brp-mangle-shebangLumir Balhar2021-09-071-1/+8
| | | | | | | | | | | If the file we are trying to mangle a shebang in has 0 lines (as reported by `wc`) `read` command fails to read the first line and the script fails silently. Text files without newlines should not be executable as there is no way for them to contain a shebang. Signed-off-by: Jani Välimaa <wally@mageia.org>
* brp-mangle-shebangs: do not exit if read has a non-zero statusJani Välimaa2019-12-241-1/+1
| | | | | | | | | At least building texlive-texmf fails without this because brp-mangle-shebangs has -e in its shebang. -e Exit immediately if a command exits with a non-zero status. $ read shebang_line < BUILD/texlive-20190410-texmf/texmf-dist/doc/generic/pst-mirror/createEPS/test.sh $ echo $? 1
* brp-mangle-shebangs: do not stat / touch files needlesslyDenys Vlasenko2019-12-231-3/+5
| | | | | | | Run "stat" to get mtime, and "touch -d $saved_mtime" only if we indeed modify file's shebang. Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
* brp-mangle-shebangs: fix unsafe/incorrect command expansionDenys Vlasenko2019-12-231-14/+19
| | | | | | | | | | | | | | | | | | | | | | | | 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>
* brp-mangle-shebangs: speed up finding of "text executables" (scripts)Denys Vlasenko2019-12-231-3/+12
| | | | Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
* Make ambiguous python shebangs errorThierry Vignaud2019-12-231-0/+1
|
* do not fail when python call is ambiguousThierry Vignaud2018-09-241-1/+0
|
* add __brp_mangle_shebangs from FC in order to:Thierry Vignaud2018-09-241-0/+142
- fix /bin -> /usr/bin - resolve "env foobar" -> "foobar" install it in /usr/lib/rpm/redhat to make clear from where it comes