Date: Sat, 29 Nov 2008 02:39:46 -0800 From: George Davidovich <freebsd@optimis.net> To: freebsd-questions@freebsd.org Subject: Re: shell scripting problems Message-ID: <20081129103946.GA35719@marvin.optimis.net> In-Reply-To: <ade45ae90811282231i15488915r773367ba75795b4c@mail.gmail.com> References: <ade45ae90811282058k8215023r80e497fa5d857c40@mail.gmail.com> <20081129060801.GA41353@shepherd> <ade45ae90811282231i15488915r773367ba75795b4c@mail.gmail.com>
next in thread | previous in thread | raw e-mail | index | archive | help
On Fri, Nov 28, 2008 at 11:31:17PM -0700, Tim Judd wrote: > On Fri, Nov 28, 2008 at 11:08 PM, Sahil Tandon <sahil@tandon.net> > wrote: > > Tim Judd <tajudd@gmail.com> wrote: > > > > I am not sure what the problem is, but are you just looking for the > > output of "pkg_info -qxL" on the *first* instance of xorg-fonts-*? > > > > % pkg_info -qL `pkg_info | grep xorg-fonts | head -1 | cut -d\ -f1` > > > > FWIW, your regexp also looks faulty. > > I'm sure it's faulty > > Which is why I'm asking for help What you were asking wasn't clear, and could have included a script problem, a port update problem, a pkg_info problem, and/or a regex problem. And then, I'm scratching my head wondering how you're making use of the output of the -L switch. > My regexes (in it's various forms) produce the output similar to: > xorg-fonts-75dpi > xorg-fonts > xorg-fonts-100dpi > ... > > and I'm wanting my regex to return the 2nd value, in this example, in > this list. If that's the case, where does your regex of "^$PKG-[0-9,._]+$" fit into all this? And why would you expect pkg_info to match on something like '^xorg-fonts$' when, AFAICT, there is no port by that name? Again, you're not being clear. > The problem is the shell is taking the end anchor $ as the start of a > variable, and no matter how I escape it, it seems to never work. The end-of-line anchors work fine. For the following I've used bash, but you can copy the same into a /bin/sh script for identical results: # PKG=cyrus # pkg_info -Ex $PKG cyrus-sasl-2.1.22_1 cyrus-sasl-saslauthd-2.1.22 # pkg_info -Ex $PKG.*1 cyrus-sasl-2.1.22_1 cyrus-sasl-saslauthd-2.1.22 # pkg_info -Ex ^$PKG.*1\$ cyrus-sasl-2.1.22_1 I'd suggest you submit your script or an abbreviated version. -- George
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20081129103946.GA35719>