bug-bash
[Top][All Lists]
Advanced

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

port of Bash examples to POSIX 1003.1-2001


From: Paul Eggert
Subject: port of Bash examples to POSIX 1003.1-2001
Date: Wed, 20 Feb 2002 03:33:45 -0800 (PST)

Configuration Information [Automatically generated, do not change]:
Machine: i686
OS: linux-gnu
Compiler: gcc
Compilation CFLAGS:  -DPROGRAM='bash' -DCONF_HOSTTYPE='i686' 
-DCONF_OSTYPE='linux-gnu' -DCONF_MACHTYPE='i686-pc-linux-gnu' 
-DCONF_VENDOR='pc' -DSHELL -DHAVE_CONFIG_H   -I.  -I.. -I../include -I../lib -g 
-O2
uname output: Linux dum.twinsun.com 2.2.18ss.e820-bda652a #4 SMP Tue Jun 5 
11:24:08 PDT 2001 i686 unknown
Machine Type: i686-pc-linux-gnu

Bash Version: 2.05a
Patch Level: 0
Release Status: release

Description:
        The new POSIX standard is now official (IEEE Std 1003.1-2001), and it
        has removed support for some obsolete utility options that the Bash
        examples use in a few places.  Basically, the new POSIX has removed
        digit-string options (e.g., "tail -1") and options beginning with "+"
        (e.g., "sort +1").

        Here is a proposed patch.  It sticks to a portable subset of the
        shell syntax, which should work on both pre-POSIX hosts and on
        hosts conforming to the new standard.

        I realize tht a more important issue is to cause Bash itself to
        conform to 1003.1-2001, but that's a different subject.

Repeat-By:

Fix:

2002-02-20  Paul Eggert  <address@hidden>

        * examples/functions/manpage, examples/functions/mhfold,
        examples/scripts.v2/pmtop, examples/scripts/bcsh.sh,
        examples/scripts/vtree2, examples/startup-files/apple/aliases:
        Port to POSIX 1003.1-2001

===================================================================
RCS file: examples/functions/manpage,v
retrieving revision 2.5.1.0
retrieving revision 2.5.1.1
diff -pu -r2.5.1.0 -r2.5.1.1
--- examples/functions/manpage  1992/11/02 16:18:04     2.5.1.0
+++ examples/functions/manpage  2002/02/20 11:28:09     2.5.1.1
@@ -25,7 +25,7 @@ function manpage ()
     set $file
     file="$1"
     if [ -f "$file" ]; then
-      zot=$(head -1 "$file")
+      zot=$(sed q "$file")
       cmd=${MANROFF:-"nroff -man - | col | cat -s"}
       h=${zot##"'"'\"'}
       if [ "$h" != "$zot" ]; then
===================================================================
RCS file: examples/functions/mhfold,v
retrieving revision 2.5.1.0
retrieving revision 2.5.1.1
diff -pu -r2.5.1.0 -r2.5.1.1
--- examples/functions/mhfold   1995/05/19 18:19:42     2.5.1.0
+++ examples/functions/mhfold   2002/02/20 11:28:09     2.5.1.1
@@ -7,7 +7,7 @@
 
 mhfold()
 {
-       list=`folders | tail +2 | awk '{print $1}'`
+       list=`folders | awk '{if (1 < NR) print $1}'`
        /bin/ls -lag ~/Mail > /tmp/fold$$
        for i in $list; do
                grep $i /tmp/fold$$
===================================================================
RCS file: examples/scripts/bcsh.sh,v
retrieving revision 2.5.1.0
retrieving revision 2.5.1.1
diff -pu -r2.5.1.0 -r2.5.1.1
--- examples/scripts/bcsh.sh    1992/02/14 18:02:46     2.5.1.0
+++ examples/scripts/bcsh.sh    2002/02/20 11:28:09     2.5.1.1
@@ -335,7 +335,7 @@ if test -s "$histfile"
        then
        cmdno="`set - \`wc -l $histfile\`;echo $1`"
        cmdno="`expr \"$cmdno\" + 1`"
-       lastcmd="`tail -1 $histfile`"
+       lastcmd="`sed -n '$p' $histfile`"
        copy=false
        ohist=$histfile
        while test ! -w "$histfile"
@@ -689,7 +689,7 @@ esac/
                                        rest=
                                        ;;
                                esac
-                               i="`grep \"$wanted\" $histfile | tail -1`"
+                               i="`grep \"$wanted\" $histfile | sed -n '$p'`"
                                ;;
                        *)
                                # find which 'start-of-command' match is wanted
@@ -708,7 +708,7 @@ esac/
                                        rest=
                                        ;;
                                esac
-                               i="`grep \"^$wanted\" $histfile | tail -1`"
+                               i="`grep \"^$wanted\" $histfile | sed -n '$p'`"
                                ;;
                        esac
 
===================================================================
RCS file: examples/scripts/vtree2,v
retrieving revision 2.5.1.0
retrieving revision 2.5.1.1
diff -pu -r2.5.1.0 -r2.5.1.1
--- examples/scripts/vtree2     1997/05/12 20:24:26     2.5.1.0
+++ examples/scripts/vtree2     2002/02/20 11:28:09     2.5.1.1
@@ -32,7 +32,7 @@ do
        cd "$1" || { shift; [ $# -ge 1 ] && echo >&2; continue; }
        echo -n "$PWD"
 
-       du $andfiles | sort +1f | sed \
+       du $andfiles | sort -k 2f | sed \
                -e 's/\([^      ]*\)    \(.*\)/\2  (\1)/' \
                -e "s#^$1##" \
                -e 's#[^/]*/\([^/]*\)$#|____\1#' \
===================================================================
RCS file: examples/scripts.v2/pmtop,v
retrieving revision 2.5.1.0
retrieving revision 2.5.1.1
diff -pu -r2.5.1.0 -r2.5.1.1
--- examples/scripts.v2/pmtop   1996/10/16 18:02:58     2.5.1.0
+++ examples/scripts.v2/pmtop   2002/02/20 11:28:09     2.5.1.1
@@ -16,7 +16,7 @@ while :
 do
        $CLEAR
        echo "$HEADER"
-       ps -aux | sort -nr +2 | sed ${SS}q
+       ps -aux | sort -nr -k 3 | sed ${SS}q
        sleep 5
 done
 
===================================================================
RCS file: examples/startup-files/apple/aliases,v
retrieving revision 2.5.1.0
retrieving revision 2.5.1.1
diff -pu -r2.5.1.0 -r2.5.1.1
--- examples/startup-files/apple/aliases        1999/04/07 19:33:56     2.5.1.0
+++ examples/startup-files/apple/aliases        2002/02/20 11:28:09     2.5.1.1
@@ -24,7 +24,7 @@ ff        () { find . -name ${1} -print 
 ll        () { ls -lag "$@" | more ; }
 word      () { fgrep -i "$*" /usr/dict/web2 ; }
 wordcount () { cat "${1}" | tr -s '    .,;:?\!()[]"' '\012' | \
-              cat -n | tail -1 | awk '{print $1}' ; }
+              awk 'END {print NR}' ; }
 
 ##
 # Read user's aliases



reply via email to

[Prev in Thread] Current Thread [Next in Thread]