Skip to contentSkip to conversation

sed s/gawk/awk/ scripts/gen_init_ramfs.sh

PATCH In review Rob Landley 7 participants 22 messages Jan 15, 2007 – Feb 3, 2007 Kbuild

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 sed s/gawk/awk/ scripts/gen_init_ramfs.sh

Use "awk" instead of "gawk".

Signature · 31 lines
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
Acked-by on v1 1/1
#1 lore raw
Quoted 1 line · Rob Landley

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

Quoted 41 lines

Use "awk" instead of "gawk".

Signature · 3 lines
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?)
scripts/gen_initramfs_list.sh +3 -3
@@ -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}"
 			;;
 		*)
Signature · 8 lines
-- 
"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/
#2 lore raw
Quoted 11 lines · On Mon, 15 Jan 2007 23:11:46 +0100 Sam Ravnborg <[email protected]> wrote:
Quoted 1 line · Rob Landley
Quoted 7 lines

Use "awk" instead of "gawk".

Signature · 3 lines
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...

#3 lore raw
Quoted 6 lines · Andrew Morton

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

Signature · 2 lines
"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
#4 lore raw

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

Quoted 7 lines · Andrew Morton
Quoted 6 lines

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.           )
#5 lore raw

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

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

---
-o--=O`C
#oo'L O
<___=E M

scripts/gen_initramfs_list.sh renamed from scripts/gen_initramfs_list.sh~ +19 -14
@@ -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}"
 			;;
#6 lore raw

PATCH 1/1 scripts/makelst: replace gawk with shell, update

In reply to Oleg Verych

scripts/makelst: replace gawk with shell, update

---
-o--=O`C
#oo'L O
<___=E M

scripts/makelst renamed from scripts/makelst~ +13 -10
@@ -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`
#7 lore raw

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

In reply to Oleg Verych
Quoted 1 line · Oleg Verych

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.

Quoted 1 line

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

Signature · 2 lines
"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
#8 lore raw

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

Quoted 7 lines · Rob Landley
Quoted 1 line · Oleg Verych

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.

Quoted 2 lines

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.

Quoted 3 lines
Quoted 1 line

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.

Quoted 6 lines

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.

Quoted 2 lines

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

Good luck !

____

#9 lore raw

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

Quoted 6 lines · Oleg Verych
Quoted 2 lines

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

Signature · 2 lines
"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
#10 lore raw

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

Quoted 11 lines · Rob Landley
Quoted 6 lines · Oleg Verych
Quoted 2 lines

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 ;)

Quoted 1 line

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

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

Thanks.
____

#11 lore raw

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

Quoted 3 lines · Oleg Verych
Quoted 1 line

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

Signature · 2 lines
"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
#12 lore raw

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

Quoted 5 lines · Rob Landley
Quoted 3 lines · Oleg Verych
Quoted 1 line

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

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

Quoted 8 lines

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.

____

#13 lore raw

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

Quoted 6 lines · Oleg Verych
Quoted 4 lines

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.

Quoted 4 lines

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

Signature · 2 lines
"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
#14 lore raw

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

Quoted 26 lines · Rob Landley
Quoted 6 lines · Oleg Verych
Quoted 4 lines

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.

Quoted 3 lines

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.

Quoted 10 lines
Quoted 4 lines

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 ;)

Quoted 7 lines

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 ;).

Quoted 4 lines

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!

____

#15 lore raw

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

Quoted 16 lines · Oleg Verych

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:~$
`-*-
Quoted 2 lines

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

#16 lore raw

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

Hallo.

Quoted 18 lines · Tim Schmielau
Quoted 16 lines · Oleg Verych

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:~$
`-*-
Quoted 5 lines
Quoted 2 lines

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 -*-

Quoted 1 line

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 )
#17 lore raw

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]

Quoted 7 lines

,-*- 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`
Quoted 5 lines

`-*-

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

Signature · 3 lines
 /) 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           (/
#18 lore raw

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

Quoted 11 lines · David Weinehall

On Sat, Jan 27, 2007 at 06:38:36AM +0000, Oleg Verych wrote:
[snip]

Quoted 9 lines

,-*- 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`

`-*-

Quoted 8 lines
Quoted 3 lines

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:-$

`-*-

____

#19 lore raw

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

In reply to Oleg Verych
Quoted 13 lines · Oleg Verych
Quoted 11 lines · Rob Landley
Quoted 6 lines · Oleg Verych
Quoted 2 lines

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.

Quoted 6 lines

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 ;)

Quoted 1 line

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

Signature · 3 lines
 /) 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           (/
#20 lore raw
In reply to Andrew Morton
Quoted 15 lines · Andrew Morton
Quoted 11 lines · On Mon, 15 Jan 2007 23:11:46 +0100 Sam Ravnborg <[email protected]> wrote:
Quoted 1 line · Rob Landley
Quoted 7 lines

Use "awk" instead of "gawk".

Signature · 3 lines
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?)
Quoted 6 lines

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

Signature · 4 lines
       "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
#21 lore raw
Quoted 4 lines

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

[]

Quoted 25 lines · Andrew Morton
Quoted 15 lines
Quoted 11 lines · On Mon, 15 Jan 2007 23:11:46 +0100 Sam Ravnborg <[email protected]> wrote:
Quoted 1 line · Rob Landley
Quoted 7 lines

Use "awk" instead of "gawk".

Signature · 3 lines
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?)
Quoted 6 lines

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.

Quoted 8 lines

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.

____