Re: [OS-BUILD PATCH 16/20] [redhat] merge-subtrees.sh: Fix syntax flagged by shellcheck

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, 13 Nov 2020 21:12:21 -0000, GitLab Bridge on behalf of bcrocker wrote:
> WARNING: I don't think this script ever would have worked, before
> or after shellcheck-suggested changes; I think the logic should be:

There is a bug but a different one. The entries in $entries are
separated by newlines, thus it's not a problem using 'read' to get
them one by one. However, 'echo $entries' would eat the newlines. It
should be 'echo "$entries"'. Which would not work as is, either, due to
the newline at the beginning and at the end of $entries.

The correct code would be:

echo "$entries" | while read -r entry; do
	[ -z "$entry" ] && continue
 	git subtree pull --prefix=$entry  master
done

Or, more explicit and less confusing,

echo "$entries" | while read -r name url; do
	[ -z "$name" ] && continue
 	git subtree pull --prefix=$name "$url" master
done

> for entry in $entries; do
>     git subtree pull --prefix=$entry  master
> done

This would not work. The $entry is split into the name and url, see my
last example above.

 Jiri
_______________________________________________
kernel mailing list -- kernel@xxxxxxxxxxxxxxxxxxxxxxx
To unsubscribe send an email to kernel-leave@xxxxxxxxxxxxxxxxxxxxxxx
Fedora Code of Conduct: https://docs.fedoraproject.org/en-US/project/code-of-conduct/
List Guidelines: https://fedoraproject.org/wiki/Mailing_list_guidelines
List Archives: https://lists.fedoraproject.org/archives/list/kernel@xxxxxxxxxxxxxxxxxxxxxxx




[Index of Archives]     [Fedora General Discussion]     [Older Fedora Users Archive]     [Fedora Advisory Board]     [Fedora Security]     [Fedora Devel Java]     [Fedora Legacy]     [Fedora Desktop]     [ATA RAID]     [Fedora Marketing]     [Fedora Mentors]     [Fedora Package Announce]     [Fedora Package Review]     [Fedora Music]     [Fedora Packaging]     [Centos]     [Fedora SELinux]     [Coolkey]     [Yum Users]     [Tux]     [Yosemite News]     [KDE Users]     [Fedora Art]     [Fedora Docs]     [USB]     [Asterisk PBX]

  Powered by Linux