FS#76035 - bash 5.2 globskipdots option will break check_dotfiles

Attached to Project: Pacman
Opened by Christoph Trassl (trassl) - Tuesday, 27 September 2022, 19:18 GMT
Last edited by Allan McRae (Allan) - Sunday, 02 October 2022, 01:46 GMT
Task Type Bug Report
Category General
Status Closed
Assigned To Allan McRae (Allan)
Architecture All
Severity Low
Priority Normal
Reported Version 6.0.1
Due in Version 6.0.2
Due Date Undecided
Percent Complete 100%
Votes 0
Private No

Details

Summary and Info:
Bash 5.2 has a new globskipdots option, which is enabled by default. This will break the check in scripts/libmakepkg/lint_package/dotfiles.sh, ie. will always return an error and building packages will fail.

--- a/scripts/libmakepkg/lint_package/dotfiles.sh.in
+++ b/scripts/libmakepkg/lint_package/dotfiles.sh.in
@@ -29,6 +29,7 @@ lint_package_functions+=('check_dotfiles')

check_dotfiles() {
local ret=0
+ shopt -u globskipdots
for f in "$pkgdir"/.*; do
[[ ${f##*/} == . || ${f##*/} == .. ]] && continue
error "$(gettext "Dotfile found in package root '%s'")" "$f"

References:
* https://lwn.net/Articles/909596/

Steps to Reproduce:
Use makepkg under bash 5.2.
This task depends upon

Closed by  Allan McRae (Allan)
Sunday, 02 October 2022, 01:46 GMT
Reason for closing:  Fixed
Additional comments about closing:  git commit a6b06a5b17e19db8700597ee06bae42b2cfe7b5a
Comment by Allan McRae (Allan) - Tuesday, 27 September 2022, 23:40 GMT
Ugh... we will need to do something else here. We support bash>=4.4.0 but...

$ shopt -u globskipdots
bash: shopt: globskipdots: invalid shell option name


I'll figure this out.
Comment by Allan McRae (Allan) - Tuesday, 27 September 2022, 23:49 GMT
In fact the glibskipdots option seems to only skip "." and "..". which is exactly what we want it to do.

What is the error you are seeing?
Comment by Christoph Trassl (trassl) - Wednesday, 28 September 2022, 00:49 GMT
When globskipdots is enabled (ie default bash 5.2) the for loop seems to run one time with the glob pattern as argument.

$ bash --noprofile --norc
$ cat ~/test.sh
find /tmp/pkgdir
echo "Showing default for globskipdots"
shopt globskipdots
echo "Enable globskipdots"
shopt -s globskipdots
for f in "/tmp/pkgdir/".*; do echo "#${f}#"; done
echo "Disable globskipdots"
shopt -u globskipdots
for f in "/tmp/pkgdir/".*; do echo "#${f}#"; done
$ bash ~/test.sh
/tmp/pkgdir
/tmp/pkgdir/path
/tmp/pkgdir/path/file
/tmp/pkgdir/file
Showing default for globskipdots
globskipdots on
Enable globskipdots
#/tmp/pkgdir/.*#
Disable globskipdots
#/tmp/pkgdir/.#
#/tmp/pkgdir/..#
$
Comment by Christoph Trassl (trassl) - Wednesday, 28 September 2022, 00:51 GMT
So this should work (not tested, though):

Edited: Removed the patch, it was just a wrong copy and paste. I will test my suggestion.
Comment by Allan McRae (Allan) - Wednesday, 28 September 2022, 01:07 GMT
Is that not a bug in the bash globskipdots implementation?
Comment by Christoph Trassl (trassl) - Wednesday, 28 September 2022, 01:07 GMT
This patch also works and does not need globskipdots to be available.
Comment by Christoph Trassl (trassl) - Wednesday, 28 September 2022, 01:09 GMT
I do not think that this is a bug. This behaviour can be tweaked with the nullglob option.
Comment by Allan McRae (Allan) - Wednesday, 28 September 2022, 01:43 GMT
ugh - I forget nullglob is not the default. Based on other usages in the codebase I'm going with:

local shellopts=$(shopt -p nullglob)
shopt -s nullglob

...

eval "$shellopts"

Loading...