bash: as a general rule, use read -r
authorZac Medico <zmedico@gentoo.org>
Wed, 29 Dec 2010 18:28:25 +0000 (10:28 -0800)
committerZac Medico <zmedico@gentoo.org>
Fri, 31 Dec 2010 06:16:57 +0000 (22:16 -0800)
This solves cases like bug #350045.

bin/ebuild-helpers/ecompressdir
bin/ebuild-helpers/prepallman
bin/ebuild-helpers/prepinfo
bin/ebuild.sh
bin/emerge-webrsync
bin/etc-update
bin/misc-functions.sh
mkrelease.sh

index 7ed2627e33df755287f88575216eddb787ebc459..7a95120a98ba0eec3854a67b68f1f8e077ef6e3d 100755 (executable)
@@ -63,7 +63,7 @@ funk_up_dir() {
        ((ret|=$?))
 
        find "${dir}" -type l -print0 | \
-       while read -d $'\0' brokenlink ; do
+       while read -r -d $'\0' brokenlink ; do
                [[ -e ${brokenlink} ]] && continue
                olddest=$(readlink "${brokenlink}")
                [[ ${act} == "compress" ]] \
@@ -86,7 +86,7 @@ _relocate_skip_dirs() {
        [[ -d ${srctree} ]] || return 0
 
        find "${srctree}" -name '*.ecompress.skip' -print0 | \
-       while read -d $'\0' src ; do
+       while read -r -d $'\0' src ; do
                src=${src%.ecompress.skip}
                dst="${dsttree}${src#${srctree}}"
                parent=${dst%/*}
index 4568bac1d4efb70b9c0359334cf4467581b4c5b2..574ab6251e47bdef3f7649fff7b650cd5fcc496e 100755 (executable)
@@ -10,7 +10,7 @@ hasq "${EAPI}" 0 1 2 3 || exit 0
 ret=0
 
 find "${D}" -type d -name man > "${T}"/prepallman.filelist
-while read mandir ; do
+while read -r mandir ; do
        mandir=${mandir#${D}}
        prepman "${mandir%/man}"
        ((ret|=$?))
index cbbba3ed0b4ac56deca56122581d5e726f226b64..9552923a324934a72991761652e8486ea95b2a1f 100755 (executable)
@@ -23,7 +23,7 @@ if [[ ! -d ${D}${infodir} ]] ; then
        fi
 fi
 
-find "${D}${infodir}" -type d -print0 | while read -d $'\0' x ; do
+find "${D}${infodir}" -type d -print0 | while read -r -d $'\0' x ; do
        for f in "${x}"/.keepinfodir*; do
                [[ -e ${f} ]] && continue 2
        done
index 4daa076104a651b7f70a93967e8f0bd71bc352a0..e88f0158dfbfc3da2e6854a438becad4bf173cab 100755 (executable)
@@ -504,7 +504,7 @@ econf() {
                if [ -e /usr/share/gnuconfig/ ]; then
                        find "${WORKDIR}" -type f '(' \
                        -name config.guess -o -name config.sub ')' -print0 | \
-                       while read -d $'\0' x ; do
+                       while read -r -d $'\0' x ; do
                                vecho " * econf: updating ${x/${WORKDIR}\/} with /usr/share/gnuconfig/${x##*/}"
                                cp -f /usr/share/gnuconfig/"${x##*/}" "${x}"
                        done
@@ -1324,7 +1324,7 @@ inherit() {
                echo "QA Notice: EXPORT_FUNCTIONS is called before inherit in" \
                        "$ECLASS.eclass. For compatibility with <=portage-2.1.6.7," \
                        "only call EXPORT_FUNCTIONS after inherit(s)." \
-                       | fmt -w 75 | while read ; do eqawarn "$REPLY" ; done
+                       | fmt -w 75 | while read -r ; do eqawarn "$REPLY" ; done
        fi
 
        local location
index e3ec5f6392c7f048fdfd1f378d645694e89b8294..195a3de2294ec98177df3dbb024f508ddbbac454 100755 (executable)
@@ -378,7 +378,7 @@ do_latest_snapshot() {
                                "use the --revert option or remove" \
                                "the timestamp file located at" \
                                "'${PORTDIR}/metadata/timestamp.x'." | fmt -w 70 | \
-                               while read line ; do
+                               while read -r line ; do
                                        ewarn "${line}"
                                done
                        r=0
index e64ef493bfc8be0356684c0202919a86b41b2930..03e9dc9fe7454dd9ea94a56b619a2d969bcba77a 100755 (executable)
@@ -206,7 +206,7 @@ user_special() {
                        echo "ERROR: user_special() called without arguments"
                        return 1
                fi
-               while read pat; do
+               while read -r pat; do
                        echo ${1} | grep "${pat}" > /dev/null && return 0
                done < ${PORTAGE_CONFIGROOT}etc/etc-update.special
        fi
index 7ad7c0d52116d4ae9121754d04d66fc9f7b54602..46be5011cebd20945de34839f48686f8a6fa346e 100755 (executable)
@@ -322,7 +322,7 @@ install_qa_check() {
                fi
 
                # Save NEEDED information after removing self-contained providers
-               scanelf -qyRF '%a;%p;%S;%r;%n' "${D}" | { while IFS= read l; do
+               scanelf -qyRF '%a;%p;%S;%r;%n' "${D}" | { while IFS= read -r l; do
                        arch=${l%%;*}; l=${l#*;}
                        obj="/${l%%;*}"; l=${l#*;}
                        soname=${l%%;*}; l=${l#*;}
@@ -664,7 +664,7 @@ install_qa_check() {
                                echo "Please do not file a Gentoo bug and instead" \
                                "report the above QA issues directly to the upstream" \
                                "developers of this software." | fmt -w 70 | \
-                               while read line ; do eqawarn "${line}" ; done
+                               while read -r line ; do eqawarn "${line}" ; done
                                eqawarn "Homepage: ${HOMEPAGE}"
                                hasq stricter ${FEATURES} && die "install aborted due to" \
                                        "poor programming practices shown above"
@@ -774,7 +774,7 @@ preinst_sfperms() {
        if hasq sfperms $FEATURES; then
                local i
                find "${D}" -type f -perm -4000 -print0 | \
-               while read -d $'\0' i ; do
+               while read -r -d $'\0' i ; do
                        if [ -n "$(find "$i" -perm -2000)" ] ; then
                                ebegin ">>> SetUID and SetGID: [chmod o-r] /${i#${D}}"
                                chmod o-r "$i"
@@ -786,7 +786,7 @@ preinst_sfperms() {
                        fi
                done
                find "${D}" -type f -perm -2000 -print0 | \
-               while read -d $'\0' i ; do
+               while read -r -d $'\0' i ; do
                        if [ -n "$(find "$i" -perm -4000)" ] ; then
                                # This case is already handled
                                # by the SetUID check above.
index c1890e443d83fe8fcd59b1ad91c29f7a58e1dfe9..e8fb98dc84b3c4af1bf8ea3e57b30428cd3f5c28 100755 (executable)
@@ -79,7 +79,7 @@ else
        git_log_opts+=" $TREE_ISH"
 fi
 skip_next=false
-git log $git_log_opts | fmt -w 80 -p "    " | while read ; do
+git log $git_log_opts | fmt -w 80 -p "    " | while read -r ; do
        if [[ $skip_next = true ]] ; then
                skip_next=false
        elif [[ $REPLY = "    svn path="* ]] ; then