[Devel] [PATCH] Using Here-doc instead of echo "..."
Igor Podlesny
openvz at poige.ru
Tue Apr 30 16:58:42 PDT 2013
-- Here-doc is generally more readable/writeable way to implement
"patterns" in SHELL.
---
etc/dists/scripts/debian-add_ip.sh | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/etc/dists/scripts/debian-add_ip.sh b/etc/dists/scripts/debian-add_ip.sh
index 2ba555a..153e67d 100755
--- a/etc/dists/scripts/debian-add_ip.sh
+++ b/etc/dists/scripts/debian-add_ip.sh
@@ -47,7 +47,8 @@ setup_network()
"${CFGFILE}-$(date --rfc-3339=seconds).bak"
}
- echo "# This configuration file is auto-generated.
+ cat > "$CFGFILE" <<__ETC_NET_INT__
+# This configuration file is auto-generated.
#
# $dont_edit, your changes will be lost.
# Please create/edit $CFGFILE.head and
@@ -57,7 +58,7 @@ setup_network()
# NOTE: it is NOT guaranteed that the contents of $CFGFILE.tail
# will be at the very end of this file.
#
-" > ${CFGFILE}
+__ETC_NET_INT__
if [ -f ${CFGFILE}.head ]; then
cat ${CFGFILE}.head >> ${CFGFILE}
@@ -84,7 +85,7 @@ iface ${LOOPBACK} inet loopback" >> ${CFGFILE}
if [ -n "${IP_ADDR}" ]; then
# Set up venet0
- echo "
+ cat >> "$CFGFILE" <<__VENET__
# Auto generated ${VENET_DEV} interface
auto ${VENET_DEV}
iface ${VENET_DEV} inet manual
@@ -93,7 +94,7 @@ iface ${VENET_DEV} inet manual
up route add default dev ${VENET_DEV}
down route del default dev ${VENET_DEV}
down ifconfig ${VENET_DEV} down
-" >> ${CFGFILE}
+__VENET__
if [ "${IPV6}" = "yes" ]; then
echo "
--
1.7.9.5
More information about the Devel
mailing list