From owner-freebsd-questions@FreeBSD.ORG Sat Nov 29 10:39:48 2008 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 8923D1065791 for ; Sat, 29 Nov 2008 10:39:48 +0000 (UTC) (envelope-from freebsd@optimis.net) Received: from mail.optimis.net (mail.optimis.net [69.104.191.124]) by mx1.freebsd.org (Postfix) with ESMTP id 3667B8FC1C for ; Sat, 29 Nov 2008 10:39:48 +0000 (UTC) (envelope-from freebsd@optimis.net) Received: from marvin.optimis.net (marvin.optimis.net [192.168.1.3]) by mail.optimis.net (8.14.2/8.14.2) with ESMTP id mATAdlX6056961 for ; Sat, 29 Nov 2008 02:39:47 -0800 (PST) (envelope-from freebsd@optimis.net) Received: from marvin.optimis.net (localhost [127.0.0.1]) by marvin.optimis.net (8.14.2/8.14.2) with ESMTP id mATAdkRR037933 for ; Sat, 29 Nov 2008 02:39:46 -0800 (PST) (envelope-from freebsd@optimis.net) Received: (from george@localhost) by marvin.optimis.net (8.14.2/8.14.2/Submit) id mATAdk5Q037932 for freebsd-questions@freebsd.org; Sat, 29 Nov 2008 02:39:46 -0800 (PST) (envelope-from freebsd@optimis.net) Date: Sat, 29 Nov 2008 02:39:46 -0800 From: George Davidovich To: freebsd-questions@freebsd.org Message-ID: <20081129103946.GA35719@marvin.optimis.net> References: <20081129060801.GA41353@shepherd> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.18 (2008-05-17) Subject: Re: shell scripting problems X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 29 Nov 2008 10:39:48 -0000 On Fri, Nov 28, 2008 at 11:31:17PM -0700, Tim Judd wrote: > On Fri, Nov 28, 2008 at 11:08 PM, Sahil Tandon > wrote: > > Tim Judd 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