On Tuesday 24 July 2007 07:56, Dan Nicholson wrote:
...
> and
> noticed some && in chained commands. It seems that usual way in LFS is
> not to do this.
Curious; is this just a style preference?
I notice in Chapter 5 Adjusting the Toolchain:
-----
GCC_INCLUDEDIR=`dirname $(gcc -print-libgcc-file-name)`/include &&
find ${GCC_INCLUDEDIR}/* -maxdepth 0 -xtype d -exec rm -rvf '{}' \; &&
rm -vf `grep -l "DO NOT EDIT THIS FILE" ${GCC_INCLUDEDIR}/*` &&
unset GCC_INCLUDEDIR
-----
And it could be replaced a bunch of ways:
1.
-----
( GCC_INCLUDEDIR=`dirname $(gcc -print-libgcc-file-name)`/include &&
find ${GCC_INCLUDEDIR}/* -maxdepth 0 -xtype d -exec rm -rvf '{}' \; &&
rm -vf `grep -l "DO NOT EDIT THIS FILE" ${GCC_INCLUDEDIR}/*`; )
-----
This one would ensure that GCC_INCLUDE is unset in the event of a failure,
probably not a big deal.
Or, if a subshell is to be avoided:
2.
-----
GCC_INCLUDEDIR=`dirname $(gcc -print-libgcc-file-name)`/include &&
find ${GCC_INCLUDEDIR}/* -maxdepth 0 -xtype d -exec rm -rvf '{}' \; &&
rm -vf `grep -l "DO NOT EDIT THIS FILE" ${GCC_INCLUDEDIR}/*` &&
unset GCC_INCLUDEDIR ||
unset GCC_INCLUDE
-----
3.
-----
Or, maybe just strip the '&&'s right out of there; I'm not sure how other
browsers and consoles work, but with my combo a cut and paste without the &&
works just fine I just have to hit enter for the last command; this also
keeps the screen output tied to the commands.
4.
-----
And finally, if there is no intention to use the '&&' as a control character
replace it with ';' and the unset will be fine.
Personally, I like the first one best. In the even that GCC_INCLUDEDIR fails
to set the following command won't go around trying to delete all directories
off the root. I played; I did; luckily I was quick with the crtl-c and not
root and only ended up deleting part of an old home directory... Now I have a
user for playing with these things ;).
Trent.
--
http://linuxfromscratch.org/mailman/listinfo/lfs-dev
FAQ: http://www.linuxfromscratch.org/faq/
Unsubscribe: See the above information page