Re: shell scripting problems

2008-11-29 Thread perryh
 In the shell script, i have a
   pkg_info -qLx ^$PKG-[0-9,._]+$
 also tried (-X)tended regex instead of the standard rege(-x).

 sh keeps erroring out saying various $ isn't a valid variable
 name ...

Both sh and csh will try to treat $ inside of  as a variable
reference.  Does it work any better if you enclose the $ in ''
instead?

If you need the first $ to be a variable reference and the second
to be used literally, you may need to do something like

  ^$PKG-[0-9,._]+'$'
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: shell scripting problems

2008-11-29 Thread George Davidovich
On Fri, Nov 28, 2008 at 11:31:17PM -0700, Tim Judd wrote:
 On Fri, Nov 28, 2008 at 11:08 PM, Sahil Tandon [EMAIL PROTECTED]
 wrote:
  Tim Judd [EMAIL PROTECTED] 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
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: shell scripting problems

2008-11-29 Thread Mel
On Saturday 29 November 2008 05:58:44 Tim Judd wrote:

 In the shell script, i have a
   pkg_info -qLx ^$PKG-[0-9,._]+$
 also tried (-X)tended regex instead of the standard rege(-x).

pkg_info -qLx ^${PKG}-[0-9,\._]+\$
-- 1--   -2-

@1: shell evaluates before regex. Use braces so that end of variable is 
explicit
@2: this shouldn't be evaluated by the shell, so escape it with a backslash. 
It's passed as dollar sign to the command.

Also, I'm relatively sure it needs -X for the + sign, but haven't tested.
-- 
Mel

Problem with today's modular software: they start with the modules
and never get to the software part.
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: shell scripting problems

2008-11-29 Thread Sahil Tandon
Tim Judd [EMAIL PROTECTED] wrote:

 I'm sure it's faulty
 
 Which is why I'm asking for help
 
 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.

In your initial message, you wished to extract the first value; now it
is the second?

 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.
 
 I'm sorry for not explaining properly.  Maybe the above would help.

It does not.  Explain exactly what you are trying to do and you will
receive more exact troubleshooting advice.  And please stop
top-posting.

-- 
Sahil Tandon [EMAIL PROTECTED]
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: shell scripting problems

2008-11-29 Thread Tim Judd
This seems to be the ticket.  I'll be watching it but now I have an example
on how to dual-quote a string.

Thanks very much, Perry

On Sat, Nov 29, 2008 at 1:37 AM, [EMAIL PROTECTED] wrote:

  In the shell script, i have a
pkg_info -qLx ^$PKG-[0-9,._]+$
  also tried (-X)tended regex instead of the standard rege(-x).
 
  sh keeps erroring out saying various $ isn't a valid variable
  name ...

 Both sh and csh will try to treat $ inside of  as a variable
 reference.  Does it work any better if you enclose the $ in ''
 instead?

 If you need the first $ to be a variable reference and the second
 to be used literally, you may need to do something like

  ^$PKG-[0-9,._]+'$'

___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to [EMAIL PROTECTED]


shell scripting problems

2008-11-28 Thread Tim Judd
Hi all,

I've been trying for a few weeks to try to get this to work, and the /bin/sh
keeps snagging the command line before passing it to pkg_info

I'll use a different shell if I need to, but since I got everything except
this one thing working, i'd rather keep it in sh

In the shell script, i have a
  pkg_info -qLx ^$PKG-[0-9,._]+$
also tried (-X)tended regex instead of the standard rege(-x).

sh keeps erroring out saying various $ isn't a valid variable name, or
pkg_info doesn't find the anything there.  And it does exist.  This all came
around with me trying to automatically update a bunch of ports.  xorg-fonts
is outdated, but xorg-fonts-100dpi or xorg-fonts-75dpi isn't.  So the regex
returns multiple values (as above).  I just want the first, hence the
anchors.

Any ideas on how to get sh to let pkg_info see everything?  Various escaping
around the end $ just doesn't work.  I'll keep working on it, but i'd like
to see how you all would suggest getting it to work.

Thanks!
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: shell scripting problems

2008-11-28 Thread Sahil Tandon
Tim Judd [EMAIL PROTECTED] wrote:

 I've been trying for a few weeks to try to get this to work, and the /bin/sh
 keeps snagging the command line before passing it to pkg_info
 
 I'll use a different shell if I need to, but since I got everything except
 this one thing working, i'd rather keep it in sh
 
 In the shell script, i have a
   pkg_info -qLx ^$PKG-[0-9,._]+$
 also tried (-X)tended regex instead of the standard rege(-x).
 
 sh keeps erroring out saying various $ isn't a valid variable name, or
 pkg_info doesn't find the anything there.  And it does exist.  This all came
 around with me trying to automatically update a bunch of ports.  xorg-fonts
 is outdated, but xorg-fonts-100dpi or xorg-fonts-75dpi isn't.  So the regex
 returns multiple values (as above).  I just want the first, hence the
 anchors.
 
 Any ideas on how to get sh to let pkg_info see everything?  Various escaping
 around the end $ just doesn't work.  I'll keep working on it, but i'd like
 to see how you all would suggest getting it to work.

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.

-- 
Sahil Tandon [EMAIL PROTECTED]
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: shell scripting problems

2008-11-28 Thread Tim Judd
I'm sure it's faulty

Which is why I'm asking for help

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.

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.

I'm sorry for not explaining properly.  Maybe the above would help.

On Fri, Nov 28, 2008 at 11:08 PM, Sahil Tandon [EMAIL PROTECTED] wrote:

 Tim Judd [EMAIL PROTECTED] wrote:

  I've been trying for a few weeks to try to get this to work, and the
 /bin/sh
  keeps snagging the command line before passing it to pkg_info
 
  I'll use a different shell if I need to, but since I got everything
 except
  this one thing working, i'd rather keep it in sh
 
  In the shell script, i have a
pkg_info -qLx ^$PKG-[0-9,._]+$
  also tried (-X)tended regex instead of the standard rege(-x).
 
  sh keeps erroring out saying various $ isn't a valid variable name, or
  pkg_info doesn't find the anything there.  And it does exist.  This all
 came
  around with me trying to automatically update a bunch of ports.
  xorg-fonts
  is outdated, but xorg-fonts-100dpi or xorg-fonts-75dpi isn't.  So the
 regex
  returns multiple values (as above).  I just want the first, hence the
  anchors.
 
  Any ideas on how to get sh to let pkg_info see everything?  Various
 escaping
  around the end $ just doesn't work.  I'll keep working on it, but i'd
 like
  to see how you all would suggest getting it to work.

 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.

 --
 Sahil Tandon [EMAIL PROTECTED]
 ___
 freebsd-questions@freebsd.org mailing list
 http://lists.freebsd.org/mailman/listinfo/freebsd-questions
 To unsubscribe, send any mail to 
 [EMAIL PROTECTED]

___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to [EMAIL PROTECTED]