[arch-projects] [netcfg] [patch] usage heredoc
Tom Vincent
tom at tlvince.com
Sun Sep 9 08:43:03 EDT 2012
I periodically noticed some slow down with `netcfg -h`. The attached
patch fixes that by replacing the many `echo` calls with a single
heredoc.
-------------- next part --------------
From 1020deb3a40243b615af25de61b3a1cac03f946e Mon Sep 17 00:00:00 2001
From: Tom Vincent <git at tlvince.com>
Date: Sun, 9 Sep 2012 19:37:23 +0800
Subject: [PATCH 1/2] Replace multiple echo calls with heredoc
---
scripts/netcfg | 36 +++++++++++++++++++-----------------
1 file changed, 19 insertions(+), 17 deletions(-)
diff --git a/scripts/netcfg b/scripts/netcfg
index f591641..c0500ec 100755
--- a/scripts/netcfg
+++ b/scripts/netcfg
@@ -12,23 +12,25 @@ version()
usage()
{
version
- echo "Usage:"
- echo " Start specified profile: netcfg profile "
- echo " Other functions: netcfg argument profile"
- echo "Arguments:"
- echo " current Report currently running profiles"
- echo "-a, all-down Take all active profiles down"
- echo "-c, check-iface Do not start profile if interface is already up"
- echo "-d, down Take specified profile down"
- echo "-D, iface-down Take down profile active on specified interface"
- echo "-h, help This help message"
- echo "-l, list List all available profiles"
- echo "-r, reconnect Disconnect and reconnect specified profile"
- echo "-R, iface-recon Reconnect profile active on specified interface"
- echo "-u, up Start specified profile"
- echo "-v, version Output version information and exit"
- echo " all-resume Resume previously suspended profiles and reconnect them"
- echo " all-suspend Store a list of current running profiles and suspend them"
+ cat << EOF
+Usage:
+ Start specified profile: netcfg profile
+ Other functions: netcfg argument profile
+Arguments:
+ current Report currently running profiles
+-a, all-down Take all active profiles down
+-c, check-iface Do not start profile if interface is already up
+-d, down Take specified profile down
+-D, iface-down Take down profile active on specified interface
+-h, help This help message
+-l, list List all available profiles
+-r, reconnect Disconnect and reconnect specified profile
+-R, iface-recon Reconnect profile active on specified interface
+-u, up Start specified profile
+-v, version Output version information and exit
+ all-resume Resume previously suspended profiles and reconnect them
+ all-suspend Store a list of current running profiles and suspend them
+EOF
}
# TODO: Re-add ROOT check and rewrite with getopts from BashFAQ
--
1.7.12
From 55fa32160743ca357cde828bc36ae56a08ddb17e Mon Sep 17 00:00:00 2001
From: Tom Vincent <git at tlvince.com>
Date: Sun, 9 Sep 2012 19:39:56 +0800
Subject: [PATCH 2/2] Rename heredoc marker to 'END' for consistency
---
scripts/netcfg | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/scripts/netcfg b/scripts/netcfg
index c0500ec..50e8528 100755
--- a/scripts/netcfg
+++ b/scripts/netcfg
@@ -12,7 +12,7 @@ version()
usage()
{
version
- cat << EOF
+ cat << END
Usage:
Start specified profile: netcfg profile
Other functions: netcfg argument profile
@@ -30,7 +30,7 @@ Arguments:
-v, version Output version information and exit
all-resume Resume previously suspended profiles and reconnect them
all-suspend Store a list of current running profiles and suspend them
-EOF
+END
}
# TODO: Re-add ROOT check and rewrite with getopts from BashFAQ
--
1.7.12
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://mailman.archlinux.org/pipermail/arch-projects/attachments/20120909/8bcd7756/attachment.asc>
More information about the arch-projects
mailing list