mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Christoph Fritz <chf.fritz@googlemail.com>
To: Sascha Hauer <s.hauer@pengutronix.de>
Cc: barebox@lists.infradead.org
Subject: Re: [PATCH] commands: add 'findstr' to get string from file
Date: Thu, 22 May 2014 11:20:37 +0200	[thread overview]
Message-ID: <1400750437.7832.28.camel@mars> (raw)
In-Reply-To: <20140521135101.GM5858@pengutronix.de>

Hi Sascha

On Wed, 2014-05-21 at 15:51 +0200, Sascha Hauer wrote:
> On Tue, May 20, 2014 at 07:27:55PM +0200, Christoph Fritz wrote:
> > Command 'findstr' can be for example used to find the string
> > "MAC=1C:BA:8C:F3:82:BB" in file /dev/eeprom0 to set the
> > appropriate variable:
> > 
> >  $ findstr -o 4 -l 17 -t eth0.ethaddr MAC /dev/eeprom0
> > 
> > Usage: findstr [OPTIONS] <STRING> <FILE>
> > Find string in file and print it
> > -o <offset>     set offset of string which gets printed
> > -l <length>     set length of string which gets printed
> > -t <var>        print into variable instead of stdio
> 
> I wonder how useful such a command is. I mean normally I would
> expect a MAC address to be stored in binary format and not ASCII.

Yes, and if a user wants to set it to another value, there is variable
'ethaddr' in 'env/network/eth0' which can be changed.

The use case here I'm facing: User wants to change 'ethaddr' and store
it in eeprom instead. If the whole /dev/eeprom0 would be a
barebox-script, it could be processed, but I can't rely on.

> Matching 'MAC' (what about the '='?) seems not very robust.

From the example above, the offset is 4 and a '=' or any other char gets
bypassed.

>  What about strings with dynamic lengths?

A more robust and flexible approach I have in mind is this: Find string
xy and delimiter z in file and optionally execute what is in between as
a command. 

> If the command is primarily intended for the MAC address then maybe
> a more dedicated command or a piece of code called from board code
> is more robust.

That's what I'm already doing here, but want to get a more general
solution for all kinds of settings.

>  If the command is intended as a general
> eeprom-variable-store then I think it's not flexible enough.

What do you think about the more robust approach from above?

 Thanks
  -- Christoph


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

      reply	other threads:[~2014-05-22  9:21 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-05-20 17:27 Christoph Fritz
2014-05-20 18:08 ` Alexander Aring
2014-05-20 20:29   ` Christoph Fritz
2014-05-21  3:44     ` Alexander Aring
2014-05-21  8:02       ` [PATCH v2] commands: add 'findstr' to search file for string Christoph Fritz
2014-05-21  9:22         ` Antony Pavlov
2014-05-21  9:49           ` Christoph Fritz
2014-05-21 13:51 ` [PATCH] commands: add 'findstr' to get string from file Sascha Hauer
2014-05-22  9:20   ` Christoph Fritz [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1400750437.7832.28.camel@mars \
    --to=chf.fritz@googlemail.com \
    --cc=barebox@lists.infradead.org \
    --cc=s.hauer@pengutronix.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox