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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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

[Index of Archives]     [Kernel Newbies]     [Netfilter]     [Bugtraq]     [Photo]     [Stuff]     [Gimp]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Video 4 Linux]     [Linux for the blind]     [Linux Resources]
  Powered by Linux