Akim Demaille wrote: > Hi Jim! > > Maybe my question below was not visible. I'd like to know > what option you prefer. ... >>> I like to avoid using pwd, because it can fail (admittedly unlikely, >>> but...). >>> Did you consider just doing the "cd" and those four commands in a sub-shell, >>> instead? >> >> Actually I lost trust in subshells :( It's too hard to have a >> shell script fail from a subshell (calling your "die" does not >> suffice). >> >> #! /bin/sh >> >> set -e >> ( >> set -e >> exit 42 >> echo end >> ) >> echo "done ($?)" >> >> $ sh /tmp/subsh.sh >> done (42) >> >> I would have expected the outer set -e to be effective. But >> I can check $? at the end if you prefer, and go with (). > > Right above. Should I stick to pwd (my preference), or do > you prefer a sub-shell?
Hi Akim, You're welcome to use pwd. set -e is in effect, so pwd failure will be caught, and changing the working directory in a script like this is not a problem. >> (Also, in some of my scripts I issue GNU Make-like "entering" >> messages for sake of Emacs, so using "cd $cwd" became more >> natural to me than relying on subshells) >> >>>> +srcdir=$(pwd) >>>> +cd "$builddir" >>>> + ./config.status --recheck >>>> + ./config.status >>>> + make >>>> + make web-manual >>>> +cd "$srcdir" >>>> +set +e >>>> + >>>> +tmp=$(mktemp -d web-doc-update.XXXXXX) || exit 1 >>>> ( cd $tmp \ >>>> && cvs -d $u...@cvs.sv.gnu.org:/webcvs/$pkg co $pkg ) >>>> -rsync -avP doc/manual/ $tmp/$pkg/manual >>>> +rsync -avP "$builddir"/doc/manual/ $tmp/$pkg/manual >>