Re: rc: Use IFS when looking for carp interfaces

2017-07-17 Thread Robert Peichaer
On Mon, Jul 17, 2017 at 03:39:29PM +0200, Klemens Nanni wrote:
> The Internal Field Seperator is meant for this so use it instead of
> reading and stripping ':' again.
> 
> Feedback? Comments?
> 
> Index: rc
> ===
> RCS file: /cvs/src/etc/rc,v
> retrieving revision 1.508
> diff -u -p -r1.508 rc
> --- rc17 Jul 2017 12:02:53 -  1.508
> +++ rc17 Jul 2017 13:33:54 -
> @@ -351,8 +350,8 @@ if [[ $1 == shutdown ]]; then
>   [[ -f /etc/rc.shutdown ]] && sh /etc/rc.shutdown
>   fi
>  
> - ifconfig | while read _if _junk; do
> - [[ $_if == carp+([0-9]): ]] && ifconfig ${_if%:} down
> + ifconfig | while IFS=: read _if _junk; do
> + [[ $_if == carp+([0-9]) ]] && ifconfig $_if down
>   done
>  
>   exit 0

Unnecessary micro optimization.

-- 
-=[rpe]=-



rc: Use IFS when looking for carp interfaces

2017-07-17 Thread Klemens Nanni
The Internal Field Seperator is meant for this so use it instead of
reading and stripping ':' again.

Feedback? Comments?

Index: rc
===
RCS file: /cvs/src/etc/rc,v
retrieving revision 1.508
diff -u -p -r1.508 rc
--- rc  17 Jul 2017 12:02:53 -  1.508
+++ rc  17 Jul 2017 13:33:54 -
@@ -351,8 +350,8 @@ if [[ $1 == shutdown ]]; then
[[ -f /etc/rc.shutdown ]] && sh /etc/rc.shutdown
fi
 
-   ifconfig | while read _if _junk; do
-   [[ $_if == carp+([0-9]): ]] && ifconfig ${_if%:} down
+   ifconfig | while IFS=: read _if _junk; do
+   [[ $_if == carp+([0-9]) ]] && ifconfig $_if down
done
 
exit 0