Mercurial > gnulib
changeset 7326:1ca1035630dd
Avoid to execute while loops in a subshell.
author | Bruno Haible <bruno@clisp.org> |
---|---|
date | Mon, 18 Sep 2006 15:14:26 +0000 |
parents | 4114613d997e |
children | 6db875979695 |
files | ChangeLog gnulib-tool |
diffstat | 2 files changed, 37 insertions(+), 17 deletions(-) [+] |
line wrap: on
line diff
--- a/ChangeLog Mon Sep 18 13:47:29 2006 +0000 +++ b/ChangeLog Mon Sep 18 15:14:26 2006 +0000 @@ -1,3 +1,8 @@ +2006-09-18 Bruno Haible <bruno@clisp.org> + + * gnulib-tool (func_import, func_create_testdir): Use exec tricks to + avoid that the while loops be executed in a subshell. + 2006-09-18 Bruno Haible <bruno@clisp.org> * MODULES.html.sh (func_module): Break long lines.
--- a/gnulib-tool Mon Sep 18 13:47:29 2006 +0000 +++ b/gnulib-tool Mon Sep 18 15:14:26 2006 +0000 @@ -22,7 +22,7 @@ progname=$0 package=gnulib -cvsdatestamp='$Date: 2006-09-18 13:07:37 $' +cvsdatestamp='$Date: 2006-09-18 15:14:26 $' last_checkin_date=`echo "$cvsdatestamp" | sed -e 's,^\$[D]ate: ,,'` version=`echo "$last_checkin_date" | sed -e 's/ .*$//' -e 's,/,-,g'` nl=' @@ -1672,17 +1672,27 @@ LC_ALL=C join -t"$delimiter" -v2 "$tmp"/old-files "$tmp"/new-files \ | sed -e "$sed_take_last_column" \ | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_new_files" > "$tmp"/added-files - while read g f; do - func_add_or_update - done < "$tmp"/added-files + { # Rearrange file descriptors. Needed because "while ... done < ..." + # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh. + exec 5<&1 < "$tmp"/added-files + while read g f; do + func_add_or_update + done + exec 1<&5 5<&- + } # Then the files that are in new-files and in old-files: already_present=true LC_ALL=C join -t"$delimiter" "$tmp"/old-files "$tmp"/new-files \ | sed -e "$sed_take_last_column" \ | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_new_files" > "$tmp"/kept-files - while read g f; do - func_add_or_update - done < "$tmp"/kept-files + { # Rearrange file descriptors. Needed because "while ... done < ..." + # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh. + exec 5<&1 < "$tmp"/kept-files + while read g f; do + func_add_or_update + done + exec 1<&5 5<&- + } # Command-line invocation printed in a comment in generated gnulib-cache.m4. actioncmd="gnulib-tool --import" @@ -2069,19 +2079,24 @@ | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_files" \ | LC_ALL=C sort \ > "$tmp"/files - while read g f; do - func_lookup_file "$f" - if test -n "$lookedup_tmp"; then - cp -p "$lookedup_file" "$testdir/$g" - else - ln "$lookedup_file" "$testdir/$g" 2>/dev/null || - if test -z "$symbolic"; then + { # Rearrange file descriptors. Needed because "while ... done < ..." + # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh. + exec 5<&1 < "$tmp"/files + while read g f; do + func_lookup_file "$f" + if test -n "$lookedup_tmp"; then cp -p "$lookedup_file" "$testdir/$g" else - ln -s "$lookedup_file" "$testdir/$g" + ln "$lookedup_file" "$testdir/$g" 2>/dev/null || + if test -z "$symbolic"; then + cp -p "$lookedup_file" "$testdir/$g" + else + ln -s "$lookedup_file" "$testdir/$g" + fi fi - fi - done < "$tmp"/files + done + exec 1<&5 5<&- + } # Create $sourcebase/Makefile.am. mkdir -p "$testdir/$sourcebase"