mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* scripts
@ 2011-02-28 16:03 Vanalme Filip
  2011-02-28 16:09 ` scripts Marc Kleine-Budde
  0 siblings, 1 reply; 10+ messages in thread
From: Vanalme Filip @ 2011-02-28 16:03 UTC (permalink / raw)
  To: barebox

I'm currently studying some Barebox scripts (i.e. init, boot) and I have noticed something strange with scripts :

barebox:/env/bin echo $bootfile
zImage
barebox:/env/bin echo $eth0.serverip
10.0.48.80
barebox:/env/bin cat test
#!/bin/sh

echo --$eth0.serverip--
echo --$bootfile--
barebox:/env/bin ./test
--10.0.48.80--
----
barebox:/env/bin

When I do an echo of the two environment variables from the command prompt, I can see their values. However, when both commands are entered in a simple script, only the serverip address appears. (I created the test script with "edit" from within Barebox). Am I doing something wrong ?


Filip


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

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: scripts
  2011-02-28 16:03 scripts Vanalme Filip
@ 2011-02-28 16:09 ` Marc Kleine-Budde
  2011-02-28 16:12   ` scripts Marc Kleine-Budde
  0 siblings, 1 reply; 10+ messages in thread
From: Marc Kleine-Budde @ 2011-02-28 16:09 UTC (permalink / raw)
  To: Vanalme Filip; +Cc: barebox


[-- Attachment #1.1: Type: text/plain, Size: 1051 bytes --]

On 02/28/2011 05:03 PM, Vanalme Filip wrote:
> I'm currently studying some Barebox scripts (i.e. init, boot) and I have noticed something strange with scripts :
> 
> barebox:/env/bin echo $bootfile
> zImage
> barebox:/env/bin echo $eth0.serverip
> 10.0.48.80
> barebox:/env/bin cat test
> #!/bin/sh
> 
> echo --$eth0.serverip--
> echo --$bootfile--

try:

echo --${bootfile}--

> barebox:/env/bin ./test
> --10.0.48.80--
> ----
> barebox:/env/bin
> 
> When I do an echo of the two environment variables from the command prompt, I can see their values. However, when both commands are entered in a simple script, only the serverip address appears. (I created the test script with "edit" from within Barebox). Am I doing something wrong ?

cheers, Marc
-- 
Pengutronix e.K.                  | Marc Kleine-Budde           |
Industrial Linux Solutions        | Phone: +49-231-2826-924     |
Vertretung West/Dortmund          | Fax:   +49-5121-206917-5555 |
Amtsgericht Hildesheim, HRA 2686  | http://www.pengutronix.de   |


[-- Attachment #1.2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 262 bytes --]

[-- Attachment #2: Type: text/plain, Size: 149 bytes --]

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

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: scripts
  2011-02-28 16:09 ` scripts Marc Kleine-Budde
@ 2011-02-28 16:12   ` Marc Kleine-Budde
  2011-03-01  8:02     ` scripts Vanalme Filip
  0 siblings, 1 reply; 10+ messages in thread
From: Marc Kleine-Budde @ 2011-02-28 16:12 UTC (permalink / raw)
  To: Vanalme Filip; +Cc: barebox


[-- Attachment #1.1: Type: text/plain, Size: 868 bytes --]

On 02/28/2011 05:09 PM, Marc Kleine-Budde wrote:
> On 02/28/2011 05:03 PM, Vanalme Filip wrote:
>> I'm currently studying some Barebox scripts (i.e. init, boot) and I have noticed something strange with scripts :
>>
>> barebox:/env/bin echo $bootfile
>> zImage
>> barebox:/env/bin echo $eth0.serverip
>> 10.0.48.80
>> barebox:/env/bin cat test
>> #!/bin/sh
>>
>> echo --$eth0.serverip--
>> echo --$bootfile--
> 
> try:
> 
> echo --${bootfile}--

If that doesn't make a difference, try to "source" the config file in
your script, e.g.:

source /env/config

cheers, Marc
-- 
Pengutronix e.K.                  | Marc Kleine-Budde           |
Industrial Linux Solutions        | Phone: +49-231-2826-924     |
Vertretung West/Dortmund          | Fax:   +49-5121-206917-5555 |
Amtsgericht Hildesheim, HRA 2686  | http://www.pengutronix.de   |


[-- Attachment #1.2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 262 bytes --]

[-- Attachment #2: Type: text/plain, Size: 149 bytes --]

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

^ permalink raw reply	[flat|nested] 10+ messages in thread

* RE: scripts
  2011-02-28 16:12   ` scripts Marc Kleine-Budde
@ 2011-03-01  8:02     ` Vanalme Filip
  2011-03-01 14:06       ` scripts Vanalme Filip
  0 siblings, 1 reply; 10+ messages in thread
From: Vanalme Filip @ 2011-03-01  8:02 UTC (permalink / raw)
  To: Marc Kleine-Budde; +Cc: barebox

> -----Original Message-----
> From: Marc Kleine-Budde [mailto:mkl@pengutronix.de]
> Sent: maandag 28 februari 2011 17:12
> To: Vanalme Filip
> Cc: barebox@lists.infradead.org
> Subject: Re: scripts
> 
> On 02/28/2011 05:09 PM, Marc Kleine-Budde wrote:
> > On 02/28/2011 05:03 PM, Vanalme Filip wrote:
> >> I'm currently studying some Barebox scripts (i.e. init, boot) and I have noticed
> something strange with scripts :
> >>
> >> barebox:/env/bin echo $bootfile
> >> zImage
> >> barebox:/env/bin echo $eth0.serverip
> >> 10.0.48.80
> >> barebox:/env/bin cat test
> >> #!/bin/sh
> >>
> >> echo --$eth0.serverip--
> >> echo --$bootfile--
> >
> > try:
> >
> > echo --${bootfile}--
> 
> If that doesn't make a difference, try to "source" the config file in your script, e.g.:
> 
> source /env/config

[Filip] 
That's it. I forgot to source the config file. Thanks!

> 
> cheers, Marc
> --
> Pengutronix e.K.                  | Marc Kleine-Budde           |
> Industrial Linux Solutions        | Phone: +49-231-2826-924     |
> Vertretung West/Dortmund          | Fax:   +49-5121-206917-5555 |
> Amtsgericht Hildesheim, HRA 2686  | http://www.pengutronix.de   |


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

^ permalink raw reply	[flat|nested] 10+ messages in thread

* RE: scripts
  2011-03-01  8:02     ` scripts Vanalme Filip
@ 2011-03-01 14:06       ` Vanalme Filip
  2011-03-01 14:11         ` scripts Marc Kleine-Budde
  0 siblings, 1 reply; 10+ messages in thread
From: Vanalme Filip @ 2011-03-01 14:06 UTC (permalink / raw)
  To: Marc Kleine-Budde; +Cc: barebox

> -----Original Message-----
> From: barebox-bounces@lists.infradead.org [mailto:barebox-
> bounces@lists.infradead.org] On Behalf Of Vanalme Filip
> Sent: dinsdag 1 maart 2011 9:02
> To: Marc Kleine-Budde
> Cc: barebox@lists.infradead.org
> Subject: RE: scripts
> 
> > -----Original Message-----
> > From: Marc Kleine-Budde [mailto:mkl@pengutronix.de]
> > Sent: maandag 28 februari 2011 17:12
> > To: Vanalme Filip
> > Cc: barebox@lists.infradead.org
> > Subject: Re: scripts
> >
> > On 02/28/2011 05:09 PM, Marc Kleine-Budde wrote:
> > > On 02/28/2011 05:03 PM, Vanalme Filip wrote:
> > >> I'm currently studying some Barebox scripts (i.e. init, boot) and I have noticed
> > something strange with scripts :
> > >>
> > >> barebox:/env/bin echo $bootfile
> > >> zImage
> > >> barebox:/env/bin echo $eth0.serverip
> > >> 10.0.48.80
> > >> barebox:/env/bin cat test
> > >> #!/bin/sh
> > >>
> > >> echo --$eth0.serverip--
> > >> echo --$bootfile--
> > >
> > > try:
> > >
> > > echo --${bootfile}--
> >
> > If that doesn't make a difference, try to "source" the config file in your script, e.g.:
> >
> > source /env/config
> 
> [Filip]
> That's it. I forgot to source the config file. Thanks!
> 

[Filip] 
One more question about barebox scripts (I guess even scripts in general...). This is part of a script from another board (that I took over for my own board):

#!/bin/sh

. /env/config

If [ x$1 = xflash ]; then
	root=flash
	kernel=flash
fi

if [ x$1 = xnet ]; then
	root=net
	kernel=net
fi

why the scripts are using i.e. [ x$1 = xflash ] instead of just simply [ $1 = flash ] ? Both are doing the same, no ?

> >
> > cheers, Marc
> > --
> > Pengutronix e.K.                  | Marc Kleine-Budde           |
> > Industrial Linux Solutions        | Phone: +49-231-2826-924     |
> > Vertretung West/Dortmund          | Fax:   +49-5121-206917-5555 |
> > Amtsgericht Hildesheim, HRA 2686  | http://www.pengutronix.de   |
> 
> 
> _______________________________________________
> barebox mailing list
> barebox@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/barebox

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

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: scripts
  2011-03-01 14:06       ` scripts Vanalme Filip
@ 2011-03-01 14:11         ` Marc Kleine-Budde
  2011-03-01 14:20           ` scripts Baruch Siach
  2011-03-02  8:36           ` scripts Vanalme Filip
  0 siblings, 2 replies; 10+ messages in thread
From: Marc Kleine-Budde @ 2011-03-01 14:11 UTC (permalink / raw)
  To: Vanalme Filip; +Cc: barebox


[-- Attachment #1.1: Type: text/plain, Size: 920 bytes --]

On 03/01/2011 03:06 PM, Vanalme Filip wrote:
[...]

> One more question about barebox scripts (I guess even scripts in
> general...). This is part of a script from another board (that I took
> over for my own board):

> #!/bin/sh
> 
> . /env/config
> 
> If [ x$1 = xflash ]; then
> 	root=flash
> 	kernel=flash
> fi
> 
> if [ x$1 = xnet ]; then
> 	root=net
> 	kernel=net
> fi
> 
> why the scripts are using i.e. [ x$1 = xflash ] instead of just simply [ $1 = flash ] ? Both are doing the same, no ?

The shell is quite old and doesn't support that. But you're right for
modern shells like bash or dash.

cheers, Marc

-- 
Pengutronix e.K.                  | Marc Kleine-Budde           |
Industrial Linux Solutions        | Phone: +49-231-2826-924     |
Vertretung West/Dortmund          | Fax:   +49-5121-206917-5555 |
Amtsgericht Hildesheim, HRA 2686  | http://www.pengutronix.de   |


[-- Attachment #1.2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 262 bytes --]

[-- Attachment #2: Type: text/plain, Size: 149 bytes --]

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

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: scripts
  2011-03-01 14:11         ` scripts Marc Kleine-Budde
@ 2011-03-01 14:20           ` Baruch Siach
  2011-03-02 16:14             ` scripts Uwe Kleine-König
  2011-03-02  8:36           ` scripts Vanalme Filip
  1 sibling, 1 reply; 10+ messages in thread
From: Baruch Siach @ 2011-03-01 14:20 UTC (permalink / raw)
  To: Marc Kleine-Budde; +Cc: barebox

Hi Marc,

On Tue, Mar 01, 2011 at 03:11:31PM +0100, Marc Kleine-Budde wrote:
> On 03/01/2011 03:06 PM, Vanalme Filip wrote:
> [...]
> 
> > One more question about barebox scripts (I guess even scripts in
> > general...). This is part of a script from another board (that I took
> > over for my own board):
> 
> > #!/bin/sh
> > 
> > . /env/config
> > 
> > If [ x$1 = xflash ]; then
> > 	root=flash
> > 	kernel=flash
> > fi
> > 
> > if [ x$1 = xnet ]; then
> > 	root=net
> > 	kernel=net
> > fi
> > 
> > why the scripts are using i.e. [ x$1 = xflash ] instead of just simply [ $1 = flash ] ? Both are doing the same, no ?
> 
> The shell is quite old and doesn't support that. But you're right for
> modern shells like bash or dash.

I get this under bash:

$ [ $UNDEF = test ]
bash: [: =: unary operator expected

However '[ "$UNDEF" = test ]' behaves as expected under bash (but not under 
hush, which is the shell of Barebox).

baruch

-- 
                                                     ~. .~   Tk Open Systems
=}------------------------------------------------ooO--U--Ooo------------{=
   - baruch@tkos.co.il - tel: +972.2.679.5364, http://www.tkos.co.il -

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

^ permalink raw reply	[flat|nested] 10+ messages in thread

* RE: scripts
  2011-03-01 14:11         ` scripts Marc Kleine-Budde
  2011-03-01 14:20           ` scripts Baruch Siach
@ 2011-03-02  8:36           ` Vanalme Filip
  2011-03-02  9:30             ` scripts Marc Kleine-Budde
  1 sibling, 1 reply; 10+ messages in thread
From: Vanalme Filip @ 2011-03-02  8:36 UTC (permalink / raw)
  To: Marc Kleine-Budde; +Cc: barebox

> -----Original Message-----
> From: Marc Kleine-Budde [mailto:mkl@pengutronix.de]
> Sent: dinsdag 1 maart 2011 15:12
> To: Vanalme Filip
> Cc: barebox@lists.infradead.org
> Subject: Re: scripts
> 
> On 03/01/2011 03:06 PM, Vanalme Filip wrote:
> [...]
> 
> > One more question about barebox scripts (I guess even scripts in
> > general...). This is part of a script from another board (that I took
> > over for my own board):
> 
> > #!/bin/sh
> >
> > . /env/config
> >
> > If [ x$1 = xflash ]; then
> > 	root=flash
> > 	kernel=flash
> > fi
> >
> > if [ x$1 = xnet ]; then
> > 	root=net
> > 	kernel=net
> > fi
> >
> > why the scripts are using i.e. [ x$1 = xflash ] instead of just simply [ $1 = flash ] ?
> Both are doing the same, no ?
> 
> The shell is quite old and doesn't support that. But you're right for modern shells
> like bash or dash.

[Filip] 
When I do :
barebox:/ echo "this is \"quoted text\""

I get :
barebox:/ this is \"quoted text\"

I would have expected this :
barebox:/ this is "quoted text"

It looks like the escape character is not working as expected.
When I have this in my boot script :
bootargs="$bootargs mtdparts=\"physmap-flash.0:$nor_parts;mxc_nand:$nand_parts\""

Will this work correctly ? Will the mtdparts be passed correctly to the kernel ? (I guess the escape character will remain, so I think it might be an problem, no?)

> 
> cheers, Marc
> 
> --
> Pengutronix e.K.                  | Marc Kleine-Budde           |
> Industrial Linux Solutions        | Phone: +49-231-2826-924     |
> Vertretung West/Dortmund          | Fax:   +49-5121-206917-5555 |
> Amtsgericht Hildesheim, HRA 2686  | http://www.pengutronix.de   |


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

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: scripts
  2011-03-02  8:36           ` scripts Vanalme Filip
@ 2011-03-02  9:30             ` Marc Kleine-Budde
  0 siblings, 0 replies; 10+ messages in thread
From: Marc Kleine-Budde @ 2011-03-02  9:30 UTC (permalink / raw)
  To: Vanalme Filip; +Cc: barebox


[-- Attachment #1.1: Type: text/plain, Size: 2015 bytes --]

On 03/02/2011 09:36 AM, Vanalme Filip wrote:
>> -----Original Message----- From: Marc Kleine-Budde
>> [mailto:mkl@pengutronix.de] Sent: dinsdag 1 maart 2011 15:12 To:
>> Vanalme Filip Cc: barebox@lists.infradead.org Subject: Re: scripts
>> 
>> On 03/01/2011 03:06 PM, Vanalme Filip wrote: [...]
>> 
>>> One more question about barebox scripts (I guess even scripts in 
>>> general...). This is part of a script from another board (that I
>>> took over for my own board):
>> 
>>> #!/bin/sh
>>> 
>>> . /env/config
>>> 
>>> If [ x$1 = xflash ]; then root=flash kernel=flash fi
>>> 
>>> if [ x$1 = xnet ]; then root=net kernel=net fi
>>> 
>>> why the scripts are using i.e. [ x$1 = xflash ] instead of just
>>> simply [ $1 = flash ] ?
>> Both are doing the same, no ?
>> 
>> The shell is quite old and doesn't support that. But you're right
>> for modern shells like bash or dash.
> 
> [Filip] When I do : barebox:/ echo "this is \"quoted text\""
> 
> I get : barebox:/ this is \"quoted text\"
> 
> I would have expected this : barebox:/ this is "quoted text"

Yeah, that's a known problem.......feel free to fix.
> 
> It looks like the escape character is not working as expected. When I
> have this in my boot script : bootargs="$bootargs
> mtdparts=\"physmap-flash.0:$nor_parts;mxc_nand:$nand_parts\""

You can remove the \". They were needed some time ago, when "mcx_nand"
needed to be the name of the Flash Chip, which contained spaces.

> Will this work correctly ? Will the mtdparts be passed correctly to 
> the kernel ? (I guess the escape character will remain, so I think
> it might be an problem, no?)

I once, or rather the kernel I used, had problems with the \"...

cheers, Marc

-- 
Pengutronix e.K.                  | Marc Kleine-Budde           |
Industrial Linux Solutions        | Phone: +49-231-2826-924     |
Vertretung West/Dortmund          | Fax:   +49-5121-206917-5555 |
Amtsgericht Hildesheim, HRA 2686  | http://www.pengutronix.de   |


[-- Attachment #1.2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 262 bytes --]

[-- Attachment #2: Type: text/plain, Size: 149 bytes --]

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

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: scripts
  2011-03-01 14:20           ` scripts Baruch Siach
@ 2011-03-02 16:14             ` Uwe Kleine-König
  0 siblings, 0 replies; 10+ messages in thread
From: Uwe Kleine-König @ 2011-03-02 16:14 UTC (permalink / raw)
  To: Baruch Siach; +Cc: barebox

On Tue, Mar 01, 2011 at 04:20:25PM +0200, Baruch Siach wrote:
> Hi Marc,
> 
> On Tue, Mar 01, 2011 at 03:11:31PM +0100, Marc Kleine-Budde wrote:
> > On 03/01/2011 03:06 PM, Vanalme Filip wrote:
> > [...]
> > 
> > > One more question about barebox scripts (I guess even scripts in
> > > general...). This is part of a script from another board (that I took
> > > over for my own board):
> > 
> > > #!/bin/sh
> > > 
> > > . /env/config
> > > 
> > > If [ x$1 = xflash ]; then
> > > 	root=flash
> > > 	kernel=flash
> > > fi
> > > 
> > > if [ x$1 = xnet ]; then
> > > 	root=net
> > > 	kernel=net
> > > fi
> > > 
> > > why the scripts are using i.e. [ x$1 = xflash ] instead of just simply [ $1 = flash ] ? Both are doing the same, no ?
> > 
> > The shell is quite old and doesn't support that. But you're right for
> > modern shells like bash or dash.
> 
> I get this under bash:
> 
> $ [ $UNDEF = test ]
> bash: [: =: unary operator expected
> 
> However '[ "$UNDEF" = test ]' behaves as expected under bash (but not under 
> hush, which is the shell of Barebox).
I didn't test it, but even if a variable is defined, I guess this might
result in trouble:

	arg=-n
	[ $arg = flash ]

(At least I remember this being the reason for using "x$arg" back when I
worked on Solaris.)

And note without quoting quite interesting things can happen, e.g.:

	test -n $arg

returns false if arg="= 42".

Best regards
Uwe

-- 
Pengutronix e.K.                           | Uwe Kleine-König            |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |

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

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2011-03-02 16:14 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-02-28 16:03 scripts Vanalme Filip
2011-02-28 16:09 ` scripts Marc Kleine-Budde
2011-02-28 16:12   ` scripts Marc Kleine-Budde
2011-03-01  8:02     ` scripts Vanalme Filip
2011-03-01 14:06       ` scripts Vanalme Filip
2011-03-01 14:11         ` scripts Marc Kleine-Budde
2011-03-01 14:20           ` scripts Baruch Siach
2011-03-02 16:14             ` scripts Uwe Kleine-König
2011-03-02  8:36           ` scripts Vanalme Filip
2011-03-02  9:30             ` scripts Marc Kleine-Budde

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox