Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
sideload-repo-systemd: Set 'nullglob' option
Previously, if there were no existing symlinks, this script would fail: wjt@camille:~$ LANG=en_GB.utf8 bash -x /usr/libexec/flatpak-create-sideload-symlinks.sh /run/media/wjt + test 1 -eq 1 + test -d /run/media/wjt + for f in "$1"/* + test -d '/run/media/wjt/*' + continue + for f in /run/flatpak/sideload-repos/automount-* + test -e '/run/flatpak/sideload-repos/automount-*' + rm '/run/flatpak/sideload-repos/automount-*' rm: cannot remove '/run/flatpak/sideload-repos/automount-*': No such file or directory This is due to the surprising POSIX shell behaviour that a glob that matches no files expands to itself, rather than to the empty list. http:https://mywiki.wooledge.org/BashFAQ/004 The POSIX solution is to add 'test -L $f' inside the loop to check if the variable actually exists. The first loop in this script uses this technique: it has a 'test -d "$f"', seen in the trace above. Bash implements a 'nullglob' feature which gives globs the behaviour you might hope for. Set it in this script.
- Loading branch information