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

Oleg Verych
2007-01-24T20:55:38Z

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