[pacman-dev] Fix srcinfo sometimes printing double newline at the end

Martin Rys spleefer90 at gmail.com
Thu Jun 25 23:09:54 UTC 2020


Hi,
this is a bit of an OCD thing, but `makepkg --printsrcinfo` usually
generates a file with two newlines at the end.

This logic happens in pacman/scripts/libmakepkg/srcinfo.sh.in
(/usr/share/makepkg/srcinfo.sh)

The relevant functions:

srcinfo_close_section() {
echo
}

srcinfo_write_global() {
...
srcinfo_open_section 'pkgbase' "${pkgbase:-$pkgname}"
srcinfo_write_section_details ''
srcinfo_close_section
}

srcinfo_write_package() {
...
srcinfo_open_section 'pkgname' "$1"
srcinfo_write_section_details "$1"
srcinfo_close_section
}

As you can see, the functions process section details, and then print
out a newline no matter if details printed something or not.

The write_section_details eventually leads to:

srcinfo_write_attr() {
...
printf "\t$attrname = %s\n" "${attrvalues[@]}"
}

Which seems to always print out a newline, so I believe the
srcinfo_close_section function is not needed there and simply
removing it and the two lines that call it would solve this issue, as
per the patchfile in the attachment.

Thanks for taking a look at this,
Marti
-------------- next part --------------
A non-text attachment was scrubbed...
Name: srcinfo.patch
Type: text/x-patch
Size: 567 bytes
Desc: not available
URL: <https://lists.archlinux.org/pipermail/pacman-dev/attachments/20200626/4002053d/attachment.bin>


More information about the pacman-dev mailing list