bug-recutils
[Top][All Lists]
Advanced

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

Re: [bug-recutils] Value Expressions


From: Jose E. Marchesi
Subject: Re: [bug-recutils] Value Expressions
Date: Tue, 21 Aug 2012 15:50:50 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.92 (gnu/linux)

Hi John.
    
    I think it would be a good idea if the recset and recins commands could
    accept some kind of "value expression" in their -s, -a and -v options.
    That is to say, whereas currently only literal strings can be given (eg:
    recset -f FEX -v "value") it would be nice to allow one to have
    recset -f FEX -v VEX
    
    For example one might wish to add a new string field which is based upon 
    another (existing) field: recset -f "field-new" -a 
"[field-existing]s/foo/bar"
    
    Or in the case of numeric fields: recset -f "field-new" -a 
"[field-existing] + 1"
    
I like the idea, but what is not clear to me is which syntax to use for
the expressions.

We could generalize the usage of sed expression syntax, including the p
(print) operator, which would be the default.  Examples:

Simple behaviour with fixed strings:

recset -f field-new -a foobar

Usage of sed-like syntax for expressions:

recset -f field-new -a "/field-existing + 1/p"

But then 'p' is the default operation, so:

recset -f field-new -a "/field-existing + 1/"

Substitution:

recset -f field-new -a "/field-existing/s/foo/bar/"

Something like that... ideas?

-- 
Jose E. Marchesi         http://www.jemarch.net
GNU Project              http://www.gnu.org



reply via email to

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