bug-recutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [bug-recutils] Value Expressions


From: John Darrington
Subject: Re: [bug-recutils] Value Expressions
Date: Tue, 4 Sep 2012 05:13:58 +0000
User-agent: Mutt/1.5.18 (2008-05-17)

On Mon, Sep 03, 2012 at 08:48:47PM +0200, Jose E. Marchesi wrote:
     
     Hi John.
     
         I hadn't really thought about the syntax, but your proposoal seems
         reasonable.
         
         Some hypotheitical use cases that I can think of are:
         
         # Add a field for a person's retirement date.
         recset -e 'Gender = Male' -f Retires -a '/date-of-birth + 65 years'
         recset -e 'Gender = Female' -f Retires -a '/date-of-birth + 55 years'
         
         # Add an a second email address to all those who work at foo.com
         recset -e 'Email[0] = "address@hidden"'  -f Email -a
         '/Email[0]/s/@foo.com/address@hidden/'
     
     Looks good but, what if you want to add a value that starts with a /
     character?  We must find a simple, complete and easy to learn syntax for
     this...

This is always going to be a problem as soon as you introduce any kind of 
expression
which is to be interpreted other than literally.  The obvious answer is, you 
must 
escape the / with a \  Another solution is, to introduce a new option -A; -A 
would
take a string to be interpreted as a value  expression, -a would be interpreted 
literally.

The trick is, like you say, is to find the solution which puts the least 
confusion
on the users.

         
         but we don't know if the element 0 is the one where the target is, so 
we need some 
         kind of positional parameter:
         
         recset -e '\(Email\) ~ "address@hidden"'  -f Email -a 
'/\1/s/@foo.com/address@hidden/'
         
         Here, the \1 represents the first field in the -e expression enclosed 
in ()
         So a more complex example:
         recset -e '#(first-name)' -e '#(last-name)' -e '#(company)' -f Email 
-a 'address@hidden'
     
     Huh... that would require to capture snapshots of the records in the
     evaluation of the SEX.  Complex stuff..
     
Hey!  Who said it was going to be easy?

J'

-- 
PGP Public key ID: 1024D/2DE827B3 
fingerprint = 8797 A26D 0854 2EAB 0285  A290 8A67 719C 2DE8 27B3
See http://keys.gnupg.net or any PGP keyserver for public key.

Attachment: signature.asc
Description: Digital signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]