Gentoo Archives: gentoo-catalyst

From: Mike Frysinger <vapier@g.o>
To: gentoo-catalyst@l.g.o
Cc: christo.kotsi@×××××.com
Subject: Re: [gentoo-catalyst] [PATCH 5/6] ln,echo and cp commands concentration
Date: Wed, 12 Apr 2017 19:24:17
Message-Id: 20170412192415.GD24205@vapier
In Reply to: [gentoo-catalyst] [PATCH 5/6] ln,echo and cp commands concentration by Christos Kotsi
1 On 12 Apr 2017 11:43, Christos Kotsi wrote:
2 > # Tweak the livecd make.conf so that users know not to edit it
3 > # https://bugs.gentoo.org/144647
4 > -mv ${clst_make_conf} ${clst_make_conf}.old
5 > -echo "####################################################" >> ${clst_make_conf}
6 > -echo "## ATTENTION: THIS IS THE MAKE.CONF ON THE LIVECD ##" >> ${clst_make_conf}
7 > -echo "## PLEASE EDIT /mnt/gentoo${clst_make_conf} INSTEAD ##" >> ${clst_make_conf}
8 > -echo "####################################################" >> ${clst_make_conf}
9 > -cat ${clst_make_conf}.old >> ${clst_make_conf}
10 > -
11 > +echo -e "####################################################\n$(cat ${clst_make_conf})" > ${clst_make_conf}
12 > +echo -e "## PLEASE EDIT /mnt/gentoo${clst_make_conf} INSTEAD ##\n$(cat ${clst_make_conf})" > ${clst_make_conf}
13 > +echo -e "## ATTENTION: THIS IS THE MAKE.CONF ON THE LIVECD ##\n$(cat ${clst_make_conf})" > ${clst_make_conf}
14 > +echo -e "####################################################\n$(cat ${clst_make_conf})" > ${clst_make_conf}
15
16 this is not an improvement:
17 - the constant cat at the end is ugly
18 - use of `echo -e` is discouraged
19 - you've incorrectly changed some things to tabs
20
21 you could write it instead:
22 old_conf=$(cat "${clst_make_conf}")
23 (
24 echo ...all...
25 echo ...the...
26 echo ...things...
27 echo "${old_conf}"
28 ) > "${clst_make_conf}"
29 -mike

Attachments

File name MIME type
signature.asc application/pgp-signature