lkml.org 
[lkml]   [2007]   [Jan]   [24]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    /
    Subject[rft] (g)awk substitution (Re: [PATCH] sed s/gawk/awk/scripts/gen_init_ramfs.sh)
    Date
    From
    > 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 majordomo@vger.kernel.org
    More majordomo info at http://vger.kernel.org/majordomo-info.html
    Please read the FAQ at http://www.tux.org/lkml/

    \
     
     \ /
      Last update: 2007-01-24 22:43    [W:0.036 / U:28.908 seconds]
    ©2003-2016 Jasper Spaans. hosted at Digital OceanAdvertise on this site