diff options
author | cperciva <cperciva@FreeBSD.org> | 2005-08-13 21:28:43 +0000 |
---|---|---|
committer | cperciva <cperciva@FreeBSD.org> | 2005-08-13 21:28:43 +0000 |
commit | 157c398c7e655325cd86c5bbf57997de4fdff9d6 (patch) | |
tree | 9dd8df67460a932ecacfc1986a3c595434aa28b8 /usr.sbin/portsnap | |
parent | 880a322170cc5efeec0ee6f6a5c308f785270915 (diff) | |
download | FreeBSD-src-157c398c7e655325cd86c5bbf57997de4fdff9d6.zip FreeBSD-src-157c398c7e655325cd86c5bbf57997de4fdff9d6.tar.gz |
Correctly exit from extract_run() and update_run() if files needed are
missing from ${WORKDIR}/files/.
This bug was caused by the astonishing interaction of "return" and
pipelines; in the following code, the "return" does not exit the
function, but instead exits the subshell which was spawned for the last
element of the pipeline; consequently, the output produced is "foo".
foo() {
echo bar | while read baz; do
if [ ${baz} = "bar" ]; then
return 1
fi
done
echo foo
}
Reported by: simon
Diffstat (limited to 'usr.sbin/portsnap')
-rw-r--r-- | usr.sbin/portsnap/portsnap/portsnap.sh | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/usr.sbin/portsnap/portsnap/portsnap.sh b/usr.sbin/portsnap/portsnap/portsnap.sh index a7731e9..bf06387 100644 --- a/usr.sbin/portsnap/portsnap/portsnap.sh +++ b/usr.sbin/portsnap/portsnap/portsnap.sh @@ -768,7 +768,7 @@ extract_metadata() { # Do the actual work involved in "extract" extract_run() { - grep "^${EXTRACTPATH}" ${WORKDIR}/INDEX | while read LINE; do + if ! grep "^${EXTRACTPATH}" ${WORKDIR}/INDEX | while read LINE; do FILE=`echo ${LINE} | cut -f 1 -d '|'` HASH=`echo ${LINE} | cut -f 2 -d '|'` echo ${PORTSDIR}/${FILE} @@ -789,7 +789,9 @@ extract_run() { -C ${PORTSDIR} ${FILE} ;; esac - done + done; then + return 1 + fi if [ ! -z "${EXTRACTPATH}" ]; then return 0; fi @@ -818,7 +820,8 @@ update_run() { # Install new files echo "Extracting new files:" - sort ${WORKDIR}/INDEX | comm -13 ${PORTSDIR}/.portsnap.INDEX - | + if ! sort ${WORKDIR}/INDEX | + comm -13 ${PORTSDIR}/.portsnap.INDEX - | while read LINE; do FILE=`echo ${LINE} | cut -f 1 -d '|'` HASH=`echo ${LINE} | cut -f 2 -d '|'` @@ -838,7 +841,9 @@ update_run() { -C ${PORTSDIR} ${FILE} ;; esac - done + done; then + return 1 + fi extract_metadata extract_indices |