2007-01-15 21:24:29

by Rob Landley

[permalink] [raw]
Subject: [PATCH] sed s/gawk/awk/ scripts/gen_init_ramfs.sh

Signed-off-by: Rob Landley <[email protected]>

Use "awk" instead of "gawk".

--

There's a symlink from awk to gawk if you're using the gnu tools, but no
symlink from gawk to awk if you're using BusyBox or some such. (There's a
reason for the existence of standard names. Can we use them please?)

--- linux-2.6.19.2/scripts/gen_initramfs_list.sh 2007-01-10 14:10:37.000000000 -0500
+++ linux-new/scripts/gen_initramfs_list.sh 2007-01-15 10:14:41.000000000 -0500
@@ -121,9 +121,9 @@
"nod")
local dev_type=
local maj=$(LC_ALL=C ls -l "${location}" | \
- gawk '{sub(/,/, "", $5); print $5}')
+ awk '{sub(/,/, "", $5); print $5}')
local min=$(LC_ALL=C ls -l "${location}" | \
- gawk '{print $6}')
+ awk '{print $6}')

if [ -b "${location}" ]; then
dev_type="b"
@@ -134,7 +134,7 @@
;;
"slink")
local target=$(LC_ALL=C ls -l "${location}" | \
- gawk '{print $11}')
+ awk '{print $11}')
str="${ftype} ${name} ${target} ${str}"
;;
*)

--
"Perfection is reached, not when there is no longer anything to add, but
when there is no longer anything to take away." - Antoine de Saint-Exupery


2007-01-15 22:11:47

by Sam Ravnborg

[permalink] [raw]
Subject: Re: [PATCH] sed s/gawk/awk/ scripts/gen_init_ramfs.sh

On Mon, Jan 15, 2007 at 04:24:17PM -0500, Rob Landley wrote:
> Signed-off-by: Rob Landley <[email protected]>
Acked-by: Sam Ravnborg <sam@ravnborg>

PS
My dev machine is broke and need a new one before kbuild.git will
be alive again.
Considering an AMD Athlon 64 X2 based one with Nvidia GeForceā„¢ 6150LE:
http://h10010.www1.hp.com/wwpc/dk/da/ho/WF06b/34307-351123-1284187-1284187-1284187-12726540-78048221.html
Anyone with comments on this choice?

Sam
>
> Use "awk" instead of "gawk".
>
> --
>
> There's a symlink from awk to gawk if you're using the gnu tools, but no
> symlink from gawk to awk if you're using BusyBox or some such. (There's a
> reason for the existence of standard names. Can we use them please?)
>
> --- linux-2.6.19.2/scripts/gen_initramfs_list.sh 2007-01-10 14:10:37.000000000 -0500
> +++ linux-new/scripts/gen_initramfs_list.sh 2007-01-15 10:14:41.000000000 -0500
> @@ -121,9 +121,9 @@
> "nod")
> local dev_type=
> local maj=$(LC_ALL=C ls -l "${location}" | \
> - gawk '{sub(/,/, "", $5); print $5}')
> + awk '{sub(/,/, "", $5); print $5}')
> local min=$(LC_ALL=C ls -l "${location}" | \
> - gawk '{print $6}')
> + awk '{print $6}')
>
> if [ -b "${location}" ]; then
> dev_type="b"
> @@ -134,7 +134,7 @@
> ;;
> "slink")
> local target=$(LC_ALL=C ls -l "${location}" | \
> - gawk '{print $11}')
> + awk '{print $11}')
> str="${ftype} ${name} ${target} ${str}"
> ;;
> *)
>
> --
> "Perfection is reached, not when there is no longer anything to add, but
> when there is no longer anything to take away." - Antoine de Saint-Exupery
> -
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to [email protected]
> More majordomo info at http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at http://www.tux.org/lkml/

2007-01-24 00:49:49

by Andrew Morton

[permalink] [raw]
Subject: Re: [PATCH] sed s/gawk/awk/ scripts/gen_init_ramfs.sh

On Mon, 15 Jan 2007 23:11:46 +0100
Sam Ravnborg <[email protected]> wrote:

> On Mon, Jan 15, 2007 at 04:24:17PM -0500, Rob Landley wrote:
> > Signed-off-by: Rob Landley <[email protected]>
> Acked-by: Sam Ravnborg <sam@ravnborg>
>
> > Use "awk" instead of "gawk".
> >
> > --
> >
> > There's a symlink from awk to gawk if you're using the gnu tools, but no
> > symlink from gawk to awk if you're using BusyBox or some such. (There's a
> > reason for the existence of standard names. Can we use them please?)

If the kernel is being compiled on a non-Linux system (eg: legacy Unix)
then it is, I guess, possible for `awk' and `gawk' to offer different
features. If the kernel's use of gawk uses GNU extensions then this patch
might break things on such a system.

I guess we'll find out...

2007-01-24 17:30:26

by Rob Landley

[permalink] [raw]
Subject: Re: [PATCH] sed s/gawk/awk/ scripts/gen_init_ramfs.sh

On Tuesday 23 January 2007 7:49 pm, Andrew Morton wrote:
> If the kernel is being compiled on a non-Linux system (eg: legacy Unix)
> then it is, I guess, possible for `awk' and `gawk' to offer different
> features. If the kernel's use of gawk uses GNU extensions then this patch
> might break things on such a system.
>
> I guess we'll find out...

I think we can rule out the "print $6" and "print $11" as gnu extensions. And
sub() is in the Single Unix Specification v3 spec for awk:

http://www.opengroup.org/onlinepubs/009695399/utilities/awk.html

I've used the busybox version and it worked just fine, once the links were
renamed.

Rob
--
"Perfection is reached, not when there is no longer anything to add, but
when there is no longer anything to take away." - Antoine de Saint-Exupery

2007-01-24 20:55:38

by Oleg Verych

[permalink] [raw]
Subject: [rft] (g)awk substitution (Re: [PATCH] sed s/gawk/awk/scripts/gen_init_ramfs.sh)

> On Tuesday 23 January 2007 7:49 pm, Andrew Morton wrote:
>> If the kernel is being compiled on a non-Linux system (eg: legacy Unix)
>> then it is, I guess, possible for `awk' and `gawk' to offer different
>> features. If the kernel's use of gawk uses GNU extensions then this patch
>> might break things on such a system.
>>
>> I guess we'll find out...

OK, this is what (g) awk is needed for:

,-*- diff: shell script -*-
| local maj=$(LC_ALL=C ls -l "${location}" | \
| - gawk
|'{sub(/,/, "", $5); print $5}')
|+ awk '{sub(/,/, "", $5); print
|$5}')
| local min=$(LC_ALL=C ls -l "${location}" | \
| - gawk
|'{print $6}')
|+ awk '{print $6}')
|
| if [ -b "${location}" ]; then
| dev_type="b"
| @@ -134,7
|+134,7 @@
| ;;
| "slink")
| local
|target=$(LC_ALL=C ls -l "${location}" | \
|- gawk '{print $11}')
|+ awk '{print $11}')
`-*-

Let me propose you to test this as solution, that need no awk, only shell:
-*- sh -*-
#/bin/sh
# usage: $0 node symlink

nod=$1
sym=$2

pos_param() {
set -- $@
shift $1
echo $1
}

location=${nod}
maj=`pos_param 5 $(LC_ALL=C ls -l "${location}")`
maj=${maj%,}
min=`pos_param 6 $(LC_ALL=C ls -l "${location}")`
echo "maj min:" $maj $min

location=${sym}
target=`pos_param 11 $(LC_ALL=C ls -l "${location}")`
echo "symlink target:" ${target}

-*- Result of testcase -*-
olecom@flower:/tmp$ ./awkless.sh /dev/null null
maj min: 1 3
symlink target: /dev/null
olecom@flower:/tmp$
olecom@flower:/tmp$
-*-

p.s. who is going to make alternative to GNU make ? ;D
---
-o--=O`C info emacs : not found /. .\ ( is there any reason to live? )
#oo'L O info make : not found o (R.I.P. Debian Operating System)
<___=E M man gcc : not found .-- ( TNX, RMS. )

2007-01-24 22:36:46

by Oleg Verych

[permalink] [raw]
Subject: [patch, rft] scripts/gen_initramfs_list.sh: replace gawk with shell, whitespace cleanup

scripts/gen_initramfs_list.sh: replace gawk with shell, whitespace cleanup

Signed-off-by: Oleg Verych <[email protected]>
---
-o--=O`C
#oo'L O
<___=E M

--- linux~2.6.20-rc5/scripts/gen_initramfs_list.sh~ 2007-01-12 19:54:26.000000000 +0100
+++ linux~2.6.20-rc5/scripts/gen_initramfs_list.sh 2007-01-24 22:54:49.721441250 +0100
@@ -1,5 +1,6 @@
#!/bin/bash
# Copyright (C) Martin Schlemmer <[email protected]>
-# Copyright (c) 2006 Sam Ravnborg <[email protected]>
+# Copyright (C) 2006 Sam Ravnborg <[email protected]>
+# Copyright (C) 2007 Oleg Verych <[email protected]>
#
# Released under the terms of the GNU GPL
@@ -18,13 +19,13 @@
$0 [-o <file>] [-u <uid>] [-g <gid>] {-d | <cpio_source>} ...
-o <file> Create gzipped initramfs file named <file> using
- gen_init_cpio and gzip
+ gen_init_cpio and gzip
-u <uid> User ID to map to user ID 0 (root).
- <uid> is only meaningful if <cpio_source>
- is a directory.
+ <uid> is only meaningful if <cpio_source>
+ is a directory.
-g <gid> Group ID to map to group ID 0 (root).
- <gid> is only meaningful if <cpio_source>
- is a directory.
+ <gid> is only meaningful if <cpio_source>
+ is a directory.
<cpio_source> File list or directory for cpio archive.
- If <cpio_source> is a .cpio file it will be used
+ If <cpio_source> is a .cpio file it will be used
as direct input to initramfs.
-d Output the default cpio list.
@@ -95,4 +96,11 @@
}

+# accessing fields, as in `awk'
+# $1 - field number; rest is argument string
+pos_param() {
+ shift $1
+ echo $1
+}
+
# for each file print a line in following format
# <filetype> <name> <path to file> <octal mode> <uid> <gid>
@@ -120,9 +128,7 @@
;;
"nod")
- local dev_type=
- local maj=$(LC_ALL=C ls -l "${location}" | \
- gawk '{sub(/,/, "", $5); print $5}')
- local min=$(LC_ALL=C ls -l "${location}" | \
- gawk '{print $6}')
+ maj=`pos_param 5 $(LC_ALL=C ls -l "${location}")`
+ min=`pos_param 6 $(LC_ALL=C ls -l "${location}")`
+ maj=${maj%,}

if [ -b "${location}" ]; then
@@ -134,6 +140,5 @@
;;
"slink")
- local target=$(LC_ALL=C ls -l "${location}" | \
- gawk '{print $11}')
+ target=`pos_param 11 $(LC_ALL=C ls -l "${location}")`
str="${ftype} ${name} ${target} ${str}"
;;

2007-01-24 23:21:40

by Oleg Verych

[permalink] [raw]
Subject: [patch, rft] scripts/makelst: replace gawk with shell, update

scripts/makelst: replace gawk with shell, update

Signed-off-by: Oleg Verych <[email protected]>
---
-o--=O`C
#oo'L O
<___=E M

--- linux~2.6.20-rc5/scripts/makelst~ 2007-01-12 19:54:26.000000000 +0100
+++ linux~2.6.20-rc5/scripts/makelst 2007-01-24 23:21:33.273657000 +0100
@@ -1,19 +1,22 @@
-#!/bin/bash
+#!/bin/sh
# A script to dump mixed source code & assembly
# with correct relocations from System.map
-# Requires the following lines in Rules.make.
-# Author(s): DJ Barrow ([email protected],[email protected])
-# William Stearns <[email protected]>
+# Requires the following lines in makefile:
#%.lst: %.c
# $(CC) $(CFLAGS) $(EXTRA_CFLAGS) $(CFLAGS_$@) -g -c -o $*.o $<
-# $(TOPDIR)/scripts/makelst $*.o $(TOPDIR)/System.map $(OBJDUMP)
+# $(srctree)/scripts/makelst $*.o $(srctree)/System.map $(OBJDUMP)
#
-# Copyright (C) 2000 IBM Corporation
-# Author(s): DJ Barrow ([email protected],[email protected])
+# Copyright (C) 2000 IBM Corporation
+# Author(s): DJ Barrow ([email protected],[email protected])
+# William Stearns <[email protected]>
#

+pos_param() {
+ shift $1 ; echo $1
+}
+
t1=`$3 --syms $1 | grep .text | grep " F " | head -n 1`
if [ -n "$t1" ]; then
- t2=`echo $t1 | gawk '{ print $6 }'`
+ t2=`pos_param 6 $t1`
if [ ! -r $2 ]; then
echo "No System.map" >&2
@@ -21,6 +24,6 @@
else
t3=`grep $t2 $2`
- t4=`echo $t3 | gawk '{ print $1 }'`
- t5=`echo $t1 | gawk '{ print $1 }'`
+ t4=`pos_param 1 $t3`
+ t5=`pos_param 1 $t1`
t6=`echo $t4 - $t5 | tr a-f A-F`
t7=`( echo ibase=16 ; echo $t6 ) | bc`

2007-01-25 01:51:47

by Rob Landley

[permalink] [raw]
Subject: Re: [rft] (g)awk substitution (Re: [PATCH] sed s/gawk/awk/scripts/gen_init_ramfs.sh)

On Wednesday 24 January 2007 4:03 pm, Oleg Verych wrote:

> Let me propose you to test this as solution, that need no awk, only shell:

Actually awk is one of the standard Single Unix Specification (version 3)
utilities and the kernel build uses it in a number of places, such as
arch/alpha/boot/Makefile, drivers/eisa/Makefile, scripts/ver_linux.

Your objection is a bit like saying "and don't use cat". I'm saying don't
call cat "gcat" when you just mean plain old cat.

> p.s. who is going to make alternative to GNU make ? ;D

Me. Seriously. It's on my todo list, as part of the Firmware Linux project:

http://lwn.net/Articles/215941/

Although as major projects go, it's about fifth down on the list after getting
toybox up to speed, writing a proper bash replacement shell, getting tcc to
build an unmodified Linux kernel, convincing the uClibc guys to HAVE ANOTHER
RELEASE ALREADY (it's been a year and a half, I _sent_ a cake)...

Today, I'm writing a gene2fs that produces streaming output (I.E. it works
like tar). It's not done yet...

Rob
--
"Perfection is reached, not when there is no longer anything to add, but
when there is no longer anything to take away." - Antoine de Saint-Exupery

2007-01-25 09:32:34

by Oleg Verych

[permalink] [raw]
Subject: sed _s_gnu_alternatives_ (Re: [rft] (g)awk substitution)

On Wed, Jan 24, 2007 at 08:51:32PM -0500, Rob Landley wrote:
> On Wednesday 24 January 2007 4:03 pm, Oleg Verych wrote:
>
> > Let me propose you to test this as solution, that need no awk, only shell:
>
> Actually awk is one of the standard Single Unix Specification (version 3)
> utilities and the kernel build uses it in a number of places, such as
> arch/alpha/boot/Makefile, drivers/eisa/Makefile, scripts/ver_linux.

I saw that. If you will test my first replacements and it will be ok,
i will go to this.

> Your objection is a bit like saying "and don't use cat". I'm saying don't
> call cat "gcat" when you just mean plain old cat.

No it's not, really. I don't want to see pipes, fork()s, disk seek,
when task can be done without it. I know, what awk is, and i hope it
will have its better time.

> > p.s. who is going to make alternative to GNU make ? ;D
>
> Me. Seriously. It's on my todo list, as part of the Firmware Linux project:

Well. I didn't expect such answer! So, after my trying to deal with
makefiles (there so many to cleanup and structure), i think it will be
easy to do so. I did contacted (ft)jam developers, but didn't get any
answer on current state of it vs GNU make.

> http://lwn.net/Articles/215941/
>
> Although as major projects go, it's about fifth down on the list after getting
> toybox up to speed, writing a proper bash replacement shell, getting tcc to
> build an unmodified Linux kernel, convincing the uClibc guys to HAVE ANOTHER
> RELEASE ALREADY (it's been a year and a half, I _sent_ a cake)...

Thanks for information.

> Today, I'm writing a gene2fs that produces streaming output (I.E. it works
> like tar). It's not done yet...

Good luck !

____

2007-01-25 18:03:53

by Rob Landley

[permalink] [raw]
Subject: Re: sed _s_gnu_alternatives_ (Re: [rft] (g)awk substitution)

On Thursday 25 January 2007 4:40 am, Oleg Verych wrote:
> > Your objection is a bit like saying "and don't use cat". I'm saying don't
> > call cat "gcat" when you just mean plain old cat.
>
> No it's not, really. I don't want to see pipes, fork()s, disk seek,
> when task can be done without it. I know, what awk is, and i hope it
> will have its better time.

*shrug* Making the need for "gawk" go away was my goal, and gawk->awk was the
minimal change. If you want more than that, I'm not objecting, just not
personally interested.

I believe "shift 5" is also SUSv3. :)

Rob
--
"Perfection is reached, not when there is no longer anything to add, but
when there is no longer anything to take away." - Antoine de Saint-Exupery

2007-01-25 19:05:43

by Oleg Verych

[permalink] [raw]
Subject: Re: sed _s_gnu_alternatives_ (Re: [rft] (g)awk substitution)

On Thu, Jan 25, 2007 at 01:03:32PM -0500, Rob Landley wrote:
> On Thursday 25 January 2007 4:40 am, Oleg Verych wrote:
> > > Your objection is a bit like saying "and don't use cat". I'm saying don't
> > > call cat "gcat" when you just mean plain old cat.
> >
> > No it's not, really. I don't want to see pipes, fork()s, disk seek,
> > when task can be done without it. I know, what awk is, and i hope it
> > will have its better time.
>
> *shrug* Making the need for "gawk" go away was my goal, and gawk->awk was the
> minimal change. If you want more than that, I'm not objecting, just not
> personally interested.

Yes making uclibc as a bit more work, than rename things ;D. And my
change is mainly from optimization point of view (say modern embedded ;)

> I believe "shift 5" is also SUSv3. :)

If you have tested, please send ack or nack to us.

Thanks.
____

2007-01-25 19:38:22

by Rob Landley

[permalink] [raw]
Subject: Re: sed _s_gnu_alternatives_ (Re: [rft] (g)awk substitution)

On Thursday 25 January 2007 2:14 pm, Oleg Verych wrote:
> > I believe "shift 5" is also SUSv3. :)
>
> If you have tested, please send ack or nack to us.

I have not. I tested the one I sent. Today I'm at a different location than
that test environment. All I can try it on here is Ubuntu, and so could you
just as easily.

As I said, I'm not particularly interested in a more intrusive solution
solving a problem I haven't actually seen. I don't see any obvious reason
why it wouldn't work, and yes it would probably also solve my problem, but I
still don't see why you think it's "better" than the three byte fix.

Rob
--
"Perfection is reached, not when there is no longer anything to add, but
when there is no longer anything to take away." - Antoine de Saint-Exupery

2007-01-25 21:09:46

by Oleg Verych

[permalink] [raw]
Subject: Re: sed _s_gnu_alternatives_ (Re: [rft] (g)awk substitution)

On Thu, Jan 25, 2007 at 02:38:02PM -0500, Rob Landley wrote:
> On Thursday 25 January 2007 2:14 pm, Oleg Verych wrote:
> > > I believe "shift 5" is also SUSv3. :)
> >
> > If you have tested, please send ack or nack to us.
>
> I have not. I tested the one I sent. Today I'm at a different location than
> that test environment. All I can try it on here is Ubuntu, and so could you
> just as easily.
>
> As I said, I'm not particularly interested in a more intrusive solution
> solving a problem I haven't actually seen. I don't see any obvious reason
> why it wouldn't work, and yes it would probably also solve my problem, but I
> still don't see why you think it's "better" than the three byte fix.

Ehhh. "I'm not guilty" issue. Well, fine ;)

If your current system is IA-32, or you have access to one, would you
like to test scripts/makelst for me, as i'm seeing `bc' there. But my
system have not one, i would like to replace it with shell or awk or
whatever. TIA.

____

2007-01-26 17:47:48

by Rob Landley

[permalink] [raw]
Subject: Re: sed _s_gnu_alternatives_ (Re: [rft] (g)awk substitution)

On Thursday 25 January 2007 4:18 pm, Oleg Verych wrote:

> > As I said, I'm not particularly interested in a more intrusive solution
> > solving a problem I haven't actually seen. I don't see any obvious reason
> > why it wouldn't work, and yes it would probably also solve my problem, but
> > I still don't see why you think it's "better" than the three byte fix.
>
> Ehhh. "I'm not guilty" issue. Well, fine ;)

"guilty"?

You attempted to hijack my simple observation ("awk is the standard name, gawk
is not") into an attempt to replace susv3 standard utilities with extra shell
script. This is a separate agenda, and I have _no_ idea why you think I'm
obligated to pursue it for you.

The motivation for my patch is taht circa 2.6.12 I didn't need gawk on my
system to build; the need for it cropped up fairly recently. This is A) an
artificial requirement, B) a regression, C) trivial to fix.

I could also teach busybox awk to be called as "gawk", but awk is the standard
name and gawk is not, and gawk can already be called as awk. The _clean_
thing to do is send a patch to get Linux to use the standard name, which I
did. This is the minimally intrusive change, and since gawk's install
creates an awk symlink it shouldn't affect any existing systems.

That's what I did. I am simply not interested in your attempts to do
something else, in hopes of fixing a problem I haven't seen and which I'm not
convinced actually exists.

> If your current system is IA-32, or you have access to one, would you
> like to test scripts/makelst for me, as i'm seeing `bc' there. But my
> system have not one, i would like to replace it with shell or awk or
> whatever. TIA.

According to Posix and SUSv3, a development environment can be expected to
have bc:
http://www.opengroup.org/onlinepubs/009695399/utilities/bc.html

Would you like to try the one in busybox?

The minimal development environment I can build a working system in is 7
packages: linux, gcc, binutils, make, busybox, uClibc, bash. This is not
theoretical: I have actually done this, and I was building systems under this
as far back as 2003. (I became busybox maintainer after spending 2 years
upgrading busybox to make this _work_. I started by rewriting sed. I didn't
_know_ sed at the time, but binutils ./configure used some rather advanced
sed scripts to build, so I fixed it. It works now.)

I'm using this to get a minimal native environment on non-x86 target
platforms, to minimize the amount of cross compiling I have to do when
bootstrapping a new platform. (I submitted an OLS tutorial proposal on this,
although I dunno if they're interested.)

Rob
--
"Perfection is reached, not when there is no longer anything to add, but
when there is no longer anything to take away." - Antoine de Saint-Exupery

2007-01-26 20:06:52

by Oleg Verych

[permalink] [raw]
Subject: Re: sed _s_gnu_alternatives_ (Re: [rft] (g)awk substitution)

On Fri, Jan 26, 2007 at 12:47:20PM -0500, Rob Landley wrote:
> On Thursday 25 January 2007 4:18 pm, Oleg Verych wrote:
>
> > > As I said, I'm not particularly interested in a more intrusive solution
> > > solving a problem I haven't actually seen. I don't see any obvious reason
> > > why it wouldn't work, and yes it would probably also solve my problem, but
> > > I still don't see why you think it's "better" than the three byte fix.
> >
> > Ehhh. "I'm not guilty" issue. Well, fine ;)
>
> "guilty"?
>
> You attempted to hijack my simple observation ("awk is the standard name, gawk
> is not") into an attempt to replace susv3 standard utilities with extra shell
> script. This is a separate agenda, and I have _no_ idea why you think I'm
> obligated to pursue it for you.
>
> The motivation for my patch is taht circa 2.6.12 I didn't need gawk on my
> system to build; the need for it cropped up fairly recently. This is A) an
> artificial requirement, B) a regression, C) trivial to fix.
>
> I could also teach busybox awk to be called as "gawk", but awk is the standard
> name and gawk is not, and gawk can already be called as awk. The _clean_
> thing to do is send a patch to get Linux to use the standard name, which I
> did. This is the minimally intrusive change, and since gawk's install
> creates an awk symlink it shouldn't affect any existing systems.
>
> That's what I did. I am simply not interested in your attempts to do
> something else, in hopes of fixing a problem I haven't seen and which I'm not
> convinced actually exists.

IMHO every embedded developer besides size cares about speed and
reducing complexity of simple things. Yes, this is orthogonal to that,
you want to say to me.

Only thing i wanted to have as reasult is ack or nack on my patch.
Everything else is outside LKML.

> > If your current system is IA-32, or you have access to one, would you
> > like to test scripts/makelst for me, as i'm seeing `bc' there. But my
> > system have not one, i would like to replace it with shell or awk or
> > whatever. TIA.
>
> According to Posix and SUSv3, a development environment can be expected to
> have bc:
> http://www.opengroup.org/onlinepubs/009695399/utilities/bc.html
>
> Would you like to try the one in busybox?

In Debian's version it has no `bc', while native `bc' is producing
crap like that:
,-*- bash -*-
|olecom@flower:~$ printf "%u" $(( -1 )) ; echo
|18446744073709551615
|olecom@flower:~$ echo -1 | bc
|-1
|olecom@flower:~$ printf "%u" $(( 0xFF )) ; echo
|255
|olecom@flower:~$ echo FF | bc
|99
|olecom@flower:~$ echo F | bc
|15
|olecom@flower:~$
`-*-

i can't understand the result... I think linux/scripts/makelst may be
updated to have sh's version of address calculation ;)

> The minimal development environment I can build a working system in is 7
> packages: linux, gcc, binutils, make, busybox, uClibc, bash. This is not
> theoretical: I have actually done this, and I was building systems under this
> as far back as 2003. (I became busybox maintainer after spending 2 years
> upgrading busybox to make this _work_. I started by rewriting sed. I didn't
> _know_ sed at the time, but binutils ./configure used some rather advanced
> sed scripts to build, so I fixed it. It works now.)

I'm glad. All i can say in this context: do you know `dash' shell.
It's pretty much OK for not interactive use, small, fast, POSIX
compliant (or should be ;).

> I'm using this to get a minimal native environment on non-x86 target
> platforms, to minimize the amount of cross compiling I have to do when
> bootstrapping a new platform. (I submitted an OLS tutorial proposal on this,
> although I dunno if they're interested.)

Goodluck!

____

2007-01-27 00:18:33

by Tim Schmielau

[permalink] [raw]
Subject: Re: sed _s_gnu_alternatives_ (Re: [rft] (g)awk substitution)

On Fri, 26 Jan 2007, Oleg Verych wrote:

> In Debian's version it has no `bc', while native `bc' is producing
> crap like that:
> ,-*- bash -*-
> |olecom@flower:~$ printf "%u" $(( -1 )) ; echo
> |18446744073709551615
> |olecom@flower:~$ echo -1 | bc
> |-1
> |olecom@flower:~$ printf "%u" $(( 0xFF )) ; echo
> |255
> |olecom@flower:~$ echo FF | bc
> |99
> |olecom@flower:~$ echo F | bc
> |15
> |olecom@flower:~$
> `-*-
>
> i can't understand the result... I think linux/scripts/makelst may be
> updated to have sh's version of address calculation ;)

No, IMHO that should not be a reason to change anything in the kernel.
Just set ibase=16 or read the fine manual:
info '(bc)About Expressions and Special Variables'

Tim

2007-01-27 06:30:27

by Oleg Verych

[permalink] [raw]
Subject: scripts/makelst: bc -> shell Re: sed _s_gnu_alternatives_ (Re: [rft] (g)awk substitution)

Hallo.

On Sat, Jan 27, 2007 at 01:18:30AM +0100, Tim Schmielau wrote:
> On Fri, 26 Jan 2007, Oleg Verych wrote:
>
> > In Debian's version it has no `bc', while native `bc' is producing
> > crap like that:
> > ,-*- bash -*-
> > |olecom@flower:~$ printf "%u" $(( -1 )) ; echo
> > |18446744073709551615
> > |olecom@flower:~$ echo -1 | bc
> > |-1
> > |olecom@flower:~$ printf "%u" $(( 0xFF )) ; echo
> > |255
> > |olecom@flower:~$ echo FF | bc
> > |99
> > |olecom@flower:~$ echo F | bc
> > |15
> > |olecom@flower:~$
> > `-*-
> >
> > i can't understand the result... I think linux/scripts/makelst may be
> > updated to have sh's version of address calculation ;)
>
> No, IMHO that should not be a reason to change anything in the kernel.
> Just set ibase=16 or read the fine manual:

Thank you very much ;) Maybe i must use XSLT with 0.99 kernel, or
what?

I'm talking about patch posted here:
Message-ID: <E1H9rZ3-0002T5-Po@flower>
Archived-At: <http://permalink.gmane.org/gmane.linux.kernel/485999>

,-*- diff snip -*-
|- t4=`echo $t3 | gawk '{ print $1 }'`
|- t5=`echo $t1 | gawk '{ print $1 }'`
|+ t4=`pos_param 1 $t3`
|+ t5=`pos_param 1 $t1`
5 t6=`echo $t4 - $t5 | tr a-f A-F`
6 t7=`( echo ibase=16 ; echo $t6 ) | bc`
`-*-

I've just noticed, that things on lines 5 and 6 may be optimized.

t7=`printf "%lu" $(( 0x$t4 - 0x$t5 ))`

No tr, no bc, no pipes -- magic!
Better know and use our *fine shell*.

And if you jouined us, Tim, maybe can share your experience and test
patch above and this one, please?
Message-ID: <E1H9qr4-0002Nu-RL@flower>
Archived-At: <http://permalink.gmane.org/gmane.linux.kernel/485984>

It's just my optimization hint. I have no bc, and i'm sure
things, like that will cause silent misinformation.

Anyway, what is so bad in `sh'?

Thanks.

-*- OT -*-
> info '(bc)About Expressions and Special Variables'
GFDL. Enough of that bull, even Documentation/ is *free* from it.

Good bye.
--
-o--=O`C info emacs : not found /. .\ ( is there any reason to live? )
#oo'L O info make : not found o ( yes --- R.I.P. FSF+RMS )
<___=E M man gcc : not found `-- ( viva Debian Operating System )

2007-02-02 16:36:18

by Adrian Bunk

[permalink] [raw]
Subject: Re: [PATCH] sed s/gawk/awk/ scripts/gen_init_ramfs.sh

On Tue, Jan 23, 2007 at 04:49:44PM -0800, Andrew Morton wrote:
> On Mon, 15 Jan 2007 23:11:46 +0100
> Sam Ravnborg <[email protected]> wrote:
>
> > On Mon, Jan 15, 2007 at 04:24:17PM -0500, Rob Landley wrote:
> > > Signed-off-by: Rob Landley <[email protected]>
> > Acked-by: Sam Ravnborg <sam@ravnborg>
> >
> > > Use "awk" instead of "gawk".
> > >
> > > --
> > >
> > > There's a symlink from awk to gawk if you're using the gnu tools, but no
> > > symlink from gawk to awk if you're using BusyBox or some such. (There's a
> > > reason for the existence of standard names. Can we use them please?)
>
> If the kernel is being compiled on a non-Linux system (eg: legacy Unix)
> then it is, I guess, possible for `awk' and `gawk' to offer different
> features. If the kernel's use of gawk uses GNU extensions then this patch
> might break things on such a system.
>
> I guess we'll find out...

Not only legacy systems.

E.g. in Debian GNU/Linux you must have at least one AWK implementation
installed, and awk is a symlink to one of them (both is done by the
package manager).

Available AWK implementations are:
- GNU AWK
- Mawk
- the original AWK

cu
Adrian

--

"Is there not promise of rain?" Ling Tan asked suddenly out
of the darkness. There had been need of rain for many days.
"Only a promise," Lao Er said.
Pearl S. Buck - Dragon Seed

2007-02-02 21:01:40

by Oleg Verych

[permalink] [raw]
Subject: Re: [PATCH] sed s/gawk/awk/ scripts/gen_init_ramfs.sh

> From: Adrian Bunk
> Newsgroups: gmane.linux.kernel
> Subject: Re: [PATCH] sed s/gawk/awk/ scripts/gen_init_ramfs.sh
> Date: Fri, 2 Feb 2007 17:36:20 +0100
[]
> On Tue, Jan 23, 2007 at 04:49:44PM -0800, Andrew Morton wrote:
>> On Mon, 15 Jan 2007 23:11:46 +0100
>> Sam Ravnborg <[email protected]> wrote:
>>
>> > On Mon, Jan 15, 2007 at 04:24:17PM -0500, Rob Landley wrote:
>> > > Signed-off-by: Rob Landley <[email protected]>
>> > Acked-by: Sam Ravnborg <sam@ravnborg>
>> >
>> > > Use "awk" instead of "gawk".
>> > >
>> > > --
>> > >
>> > > There's a symlink from awk to gawk if you're using the gnu tools, but no
>> > > symlink from gawk to awk if you're using BusyBox or some such. (There's a
>> > > reason for the existence of standard names. Can we use them please?)
>>
>> If the kernel is being compiled on a non-Linux system (eg: legacy Unix)
>> then it is, I guess, possible for `awk' and `gawk' to offer different
>> features. If the kernel's use of gawk uses GNU extensions then this patch
>> might break things on such a system.
>>
>> I guess we'll find out...
>
> Not only legacy systems.
>
> E.g. in Debian GNU/Linux you must have at least one AWK implementation
> installed, and awk is a symlink to one of them (both is done by the
> package manager).
>
> Available AWK implementations are:
> - GNU AWK
> - Mawk
> - the original AWK

Well, i'm looking for anyone to comment on my respond to this "issue".
Probably noone has much time to do this. Anyway, please see my patch:

Message-ID: <[email protected]>
Archived-At: <http://permalink.gmane.org/gmane.linux.kernel/488044>

Thanks.

____

2007-02-03 11:13:10

by David Weinehall

[permalink] [raw]
Subject: Re: sed _s_gnu_alternatives_ (Re: [rft] (g)awk substitution)

On Thu, Jan 25, 2007 at 07:14:07PM +0000, Oleg Verych wrote:
> On Thu, Jan 25, 2007 at 01:03:32PM -0500, Rob Landley wrote:
> > On Thursday 25 January 2007 4:40 am, Oleg Verych wrote:
> > > > Your objection is a bit like saying "and don't use cat". I'm saying don't
> > > > call cat "gcat" when you just mean plain old cat.
> > >
> > > No it's not, really. I don't want to see pipes, fork()s, disk seek,
> > > when task can be done without it. I know, what awk is, and i hope it
> > > will have its better time.
> >
> > *shrug* Making the need for "gawk" go away was my goal, and gawk->awk was the
> > minimal change. If you want more than that, I'm not objecting, just not
> > personally interested.
>
> Yes making uclibc as a bit more work, than rename things ;D. And my
> change is mainly from optimization point of view (say modern embedded ;)
>
> > I believe "shift 5" is also SUSv3. :)
>
> If you have tested, please send ack or nack to us.

Yes, shift [n] is available in SuSv3:

http://www.opengroup.org/onlinepubs/009695399/utilities/shift.html


Regards: David
--
/) David Weinehall <[email protected]> /) Northern lights wander (\
// Maintainer of the v2.0 kernel // Dance across the winter sky //
\) http://www.acc.umu.se/~tao/ (/ Full colour fire (/

2007-02-03 11:25:08

by David Weinehall

[permalink] [raw]
Subject: Re: scripts/makelst: bc -> shell Re: sed _s_gnu_alternatives_ (Re: [rft] (g)awk substitution)

On Sat, Jan 27, 2007 at 06:38:36AM +0000, Oleg Verych wrote:
[snip]
> ,-*- diff snip -*-
> |- t4=`echo $t3 | gawk '{ print $1 }'`
> |- t5=`echo $t1 | gawk '{ print $1 }'`
> |+ t4=`pos_param 1 $t3`
> |+ t5=`pos_param 1 $t1`
> 5 t6=`echo $t4 - $t5 | tr a-f A-F`
> 6 t7=`( echo ibase=16 ; echo $t6 ) | bc`
> `-*-
>
> I've just noticed, that things on lines 5 and 6 may be optimized.
>
> t7=`printf "%lu" $(( 0x$t4 - 0x$t5 ))`

%lu does not seem to agree with SuSv3:

http://www.opengroup.org/onlinepubs/009695399/utilities/printf.html
http://www.opengroup.org/onlinepubs/009695399/basedefs/xbd_chap05.html

[snip]


Regards: David Weinehall
--
/) David Weinehall <[email protected]> /) Northern lights wander (\
// Maintainer of the v2.0 kernel // Dance across the winter sky //
\) http://www.acc.umu.se/~tao/ (/ Full colour fire (/

2007-02-03 13:02:10

by Oleg Verych

[permalink] [raw]
Subject: Re: scripts/makelst: bc -> shell Re: sed _s_gnu_alternatives_ (Re: [rft] (g)awk substitution)

On Sat, Feb 03, 2007 at 12:24:59PM +0100, David Weinehall wrote:
> On Sat, Jan 27, 2007 at 06:38:36AM +0000, Oleg Verych wrote:
> [snip]
> > ,-*- diff snip -*-
> > |- t4=`echo $t3 | gawk '{ print $1 }'`
> > |- t5=`echo $t1 | gawk '{ print $1 }'`
> > |+ t4=`pos_param 1 $t3`
> > |+ t5=`pos_param 1 $t1`
> > 5 t6=`echo $t4 - $t5 | tr a-f A-F`
> > 6 t7=`( echo ibase=16 ; echo $t6 ) | bc`
> > `-*-
> >
> > I've just noticed, that things on lines 5 and 6 may be optimized.
> >
> > t7=`printf "%lu" $(( 0x$t4 - 0x$t5 ))`
>
> %lu does not seem to agree with SuSv3:
>
> http://www.opengroup.org/onlinepubs/009695399/utilities/printf.html
> http://www.opengroup.org/onlinepubs/009695399/basedefs/xbd_chap05.html

,-*- xbd_chap05.html -*-
| The EXTENDED DESCRIPTION section almost exactly matches the
| printf() function in the ISO C standard, although it is described
| in terms of the file format notation in the Base Definitions volume
| of IEEE Std 1003.1-2001, Chapter 5, File Format Notation.
`-*-
In other words, it does *not* match it at all. How it can without
the length modifiers?

As for me, "shalls" and "shoulds", "Implementations are encouraged" are
standard terms of The Standards.

Thus, i think, "%ul" is more "implementation wise":

,-*- printf test on bash, dash, busybox -*-
|olecom@flower:~$
|olecom@flower:~$ printf "%u \n" 0xffffffffffffffff
|18446744073709551615
|olecom@flower:~$ printf "%u \n" 0xffffffffffffffffA
|bash: printf: warning: 0xffffffffffffffffA: Numerical result out of range
|18446744073709551615
|olecom@flower:~$
|olecom@flower:~$ echo $BASH_VERSION
|3.1.17(1)-release
|olecom@flower:~$
|olecom@flower:~$ /bin/dash
|flower:-$ printf "%u \n" 0xffffffffffffffff
|18446744073709551615
|flower:-$ printf "%u \n" 0xffffffffffffffffA
|printf: 2: 0xffffffffffffffffA: Numerical result out of range
|18446744073709551615
|flower:-$
|flower:-$ /bin/busybox sh
|
|
|BusyBox v1.1.3 (Debian 1:1.1.3-4) Built-in shell (ash)
|Enter 'help' for a list of built-in commands.
|
|flower:-$
|flower:-$
|flower:-$ printf "%u \n" 0xffffffffffffffff
|4294967295
|flower:-$ printf "%u \n" 0xffffffffffffffffA
|0xffffffffffffffffA4294967295
|flower:-$ printf "%lu \n" 0xffffffffffffffff
|18446744073709551615
|flower:-$ printf "%lu \n" 0xffffffffffffffffA
|0xffffffffffffffffA18446744073709551615
|flower:-$
|flower:-$
`-*-

____