MSYS2-packages/pacman/0022-pacman.c-handle-cr-on-stdin-as-well.patch
Christoph Reiter 1915a138c0 pacman: Update to 6.1.0 (v2)
Same as #4584 but with an additional backport:
https://github.com/msys2/msys2-pacman/pull/49

Old message:

See msys2/msys2-pacman#45

makepkg.conf synced with the upstream version:
https://gitlab.archlinux.org/pacman/pacman/-/blob/v6.1.0/etc/makepkg.conf.in

Skip patches only changing CI configs
2024-05-09 09:45:39 +02:00

42 lines
1.2 KiB
Diff

From b9a541124a85c8954147de3c1716dfb1e33b2357 Mon Sep 17 00:00:00 2001
From: Christopher Degawa <ccom@randomderp.com>
Date: Wed, 18 Aug 2021 10:00:26 -0500
Subject: [PATCH 22/N] pacman.c: handle cr on stdin as well
Improves compatibility with Windows targets, specifically when using
powershell for string transforming package names and piping into
pacman as it's virtually impossible to send newline only terminated
strings through pipes
Allows for stuff such as
```powershell
$a="vim nano"
$b="cmake ninja"
$a.Split(' '), $b.Split(' ').ForEach({Write-Output mingw-w64-ucrt-x86_64-$_}) |
pacman -S --needed -
```
Signed-off-by: Christopher Degawa <ccom@randomderp.com>
---
src/pacman/pacman.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/src/pacman/pacman.c b/src/pacman/pacman.c
index 3a25442..46c8ef8 100644
--- a/src/pacman/pacman.c
+++ b/src/pacman/pacman.c
@@ -1187,6 +1187,12 @@ int main(int argc, char *argv[])
if(line[nread - 1] == '\n') {
/* remove trailing newline */
line[nread - 1] = '\0';
+#ifdef __MSYS__
+ if (line[nread - 2] == '\r') {
+ /* remove trailing carriage returns */
+ line[nread - 2] = '\0';
+ }
+#endif
}
if(line[0] == '\0') {
/* skip empty lines */