network.subr _aliasN handling

Hiroki Sato hrs at FreeBSD.org
Sat Feb 22 05:20:46 UTC 2014


<dteske at freebsd.org> wrote
  in <11c101cf2f6b$e3aee5d0$ab0cb170$@FreeBSD.org>:

dt>
dt>
dt> > -----Original Message-----
dt> > From: John Nielsen [mailto:lists at jnielsen.net]
dt> > Sent: Friday, February 21, 2014 9:06 AM
dt> > To: Devin Teske
dt> > Cc: Jason Hellenthal; rc at freebsd.org; net at freebsd.org
dt> > Subject: Re: network.subr _aliasN handling
dt> >
dt> > On Jan 4, 2014, at 4:25 AM, Teske, Devin <Devin.Teske at fisglobal.com>
dt> wrote:
dt> >
dt> > > On Jan 4, 2014, at 2:59 AM, Jason Hellenthal wrote:
dt> > >
dt> > >> I believe I know what you mean by that but in a way scares me when
dt> you say
dt> > sort as in mixing up the original order they appear in which I would
dt> find to be
dt> > really unattractive to most.
dt> > >
dt> > > It's not as scary as it sounds.
dt> > >
dt> > > The issue is that the variables are sorted alphabetically, instead of
dt> > > numerically.
dt> > >
dt> > > Let's take four words: foo1, foo2, foo10, and foo20.
dt> > > If you sort them alphabetically, you get:
dt> > >
dt> > > 	foo1
dt> > > 	foo10
dt> > > 	foo2
dt> > > 	foo20
dt> > >
dt> > > You'll notice this when doing a directory listing, as that too is
dt> > > sorted alphabetically.
dt> > >
dt> > > This is why "alias14" is run before "alias8" and "alias9". Because
dt> > > they are processed in alphabetically sorted order. I didn't do
dt> > > anything to sort the values, they came pre-sorted in alphabetic order.
dt> > >
dt> > > If I simply throw in a "| sort -n", then it will change it to
dt> numerically sorted.
dt> > > As you might expect, numerically sorting the above list would result
dt> in:
dt> > >
dt> > > 	foo1
dt> > > 	foo2
dt> > > 	foo10
dt> > > 	foo20
dt> > >
dt> > > Trivial really. I'll throw a patch at you when I get some cycles
dt> (soon).
dt> >
dt> > Hi Devin, Jason-
dt> >
dt> > I've been behind on my mailing list e-mail for a while, but I really
dt> like the idea
dt> > and the patch proposed here. I don't see anything like it in head yet,
dt> so ... Ping?
dt> > :)
dt> >
dt> > JN
dt> >
dt> [Devin Teske]
dt>
dt> *** this time with attached patch.txt ***
dt>
dt> Hi JN, here's a new patch that incorporates numerical sorting as well as
dt> what
dt> the original patch set out to do ... make "gaps" possible (so that you
dt> could
dt> comment out an alias without having to renumber all the ones following).
dt>
dt> Give it a look, let me know what you think.

+list_vars()
+{
+	set | { while read LINE; do
+		var="${LINE%%=*}"
+		case "$var" in
+		"$LINE"|*[!a-zA-Z0-9_]*) continue ;;
+		$1) echo $var
+		esac
+	done; }
+}

 This can be inconsistent with normalization of $_if in get_if_var()
 when [.-/+] is included.

 I have no strong opinion about fixing the sequence gap issue but
 ifconfig_IF_aliases was meant for that.  This behavior is well-known
 for a very long time, so I was reluctant to change it.

-- Hiroki
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 181 bytes
Desc: not available
URL: <http://lists.freebsd.org/pipermail/freebsd-rc/attachments/20140222/0ebee502/attachment.sig>


More information about the freebsd-rc mailing list