[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Help-bash] A do nothing function
From: |
Bob Proulx |
Subject: |
Re: [Help-bash] A do nothing function |
Date: |
Thu, 27 Sep 2012 15:35:51 -0600 |
User-agent: |
Mutt/1.5.21 (2010-09-15) |
DJ Mills wrote:
> However, that raises the question of why you wouldn't ust omit the
> whole thing
Sometimes it is programmer efficiency. I sometimes run into a case
like this snippet from a hook script in 'resolvconf'. The reason
behind this isn't important here. But I didn't want to restructure
the script. I just wanted my modification to it.
RSLVCNFFILES="$(/lib/resolvconf/list-records | sed -e '/^lo$/d' -e
'/^lo[.]/d')"
I needed some special handling in a particular case. So I modified it
like this:
filter=cat
if [ -f tun0.net ]; then
filter="sed /^eth/d;/^wlan/d;/^NetworkManager/d"
fi
RSLVCNFFILES="$(/lib/resolvconf/list-records | $filter | sed -e '/^lo$/d' -e
'/^lo[.]/d')"
Then the logic flows easily and the problem is solved with a minimum
chance of error creeping into it. And it is easy to patch in the
future if the file is updated. (And yes the resolvconf maintainer and
I have discussed the issue and we are both happy with situation.)
Or I might do something like this:
case $fn in
*.gz) cat=zcat ;;
*) cat=cat ;;
esac
And then use $cat just like I would use cat but based upon the
filename it will do the right thing.
Programmer productivity and easy of maintenance is usually more
important than absolute cpu efficiency. Especially when you will
never be able to tell the difference.
Bob
- [Help-bash] A do nothing function, Peng Yu, 2012/09/27
- Re: [Help-bash] A do nothing function, DJ Mills, 2012/09/27
- Re: [Help-bash] A do nothing function,
Bob Proulx <=
- Re: [Help-bash] A do nothing function, Greg Wooledge, 2012/09/28
- Re: [Help-bash] A do nothing function, DJ Mills, 2012/09/28
- Re: [Help-bash] A do nothing function, Bob Proulx, 2012/09/28
- Re: [Help-bash] A do nothing function, Greg Wooledge, 2012/09/28
- Re: [Help-bash] A do nothing function, Bob Proulx, 2012/09/28
- Re: [Help-bash] A do nothing function, Stephane Chazelas, 2012/09/29
Re: [Help-bash] A do nothing function, Davide Brini, 2012/09/27