[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bash 2.05b port to POSIX 1003.1-2001 hosts
From: |
Paul Eggert |
Subject: |
bash 2.05b port to POSIX 1003.1-2001 hosts |
Date: |
Wed, 24 Jul 2002 01:22:23 -0700 (PDT) |
Configuration Information [Automatically generated, do not change]:
Machine: sparc
OS: solaris2.8
Compiler: gcc
Compilation CFLAGS: -DPROGRAM='bash' -DCONF_HOSTTYPE='sparc'
-DCONF_OSTYPE='solaris2.8' -DCONF_MACHTYPE='sparc-sun-solaris2.8'
-DCONF_VENDOR='sun' -DSHELL -DHAVE_CONFIG_H -I. -I. -I./include -I./lib -g
-O2 -Wall -W -Wno-sign-compare -Wpointer-arith -Wstrict-prototypes
-Wmissing-prototypes -Wmissing-noreturn -Wmissing-format-attribute
uname output: SunOS sic.twinsun.com 5.8 Generic_108528-15 sun4u sparc
SUNW,UltraSPARC-IIi-Engine
Machine Type: sparc-sun-solaris2.8
Bash Version: 2.05b
Patch Level: 0
Release Status: release
Description:
In several places, mostly in examples, Bash 2.05b uses
commands or options that have been withdrawn in POSIX 1003.1-2001.
The withdrawn commands are egrep and fgrep; portable scripts
are supposed to use grep -E and grep -F instead.
The withdrawn options are test -a (you're supposed to use &&),
test -o (you're supposed to use ||), and tail -100 (you're
supposed to use tail -n 100).
I noticed a related typo while I was fixing these problems:
examples/obashdb/bashdb.fns says
`egrep "*(${_stringbp%\|})*"' where it meant to say
`egrep "\\*(${_stringbp%\|})\\*"'.
Repeat-By:
Run the examples and/or tests on a host that strictly conforms
to POSIX 1003.1-2001. (No such host exists yet, as far as I
know, but it's possible to set up approximations with recent
versions of GNU textutils and GNU fileutils.)
Fix:
Most of the problems occur only in examples, so I just rewrote them
using POSIX code. tests/array.tests is a special case, as it should
work correctly even on older hosts that don't support 'grep -E', so
I rewrote it to use sed instead of egrep.
===================================================================
RCS file: examples/functions/coproc.bash,v
retrieving revision 2.5.2.0
retrieving revision 2.5.2.1
diff -pu -r2.5.2.0 -r2.5.2.1
--- examples/functions/coproc.bash 2001/09/24 18:24:10 2.5.2.0
+++ examples/functions/coproc.bash 2002/07/24 08:08:42 2.5.2.1
@@ -63,7 +63,7 @@ function coprocess ()
shift
local old_trap=$(trap -p SIGPIPE)
trap 'coprocess close -SIGPIPE' SIGPIPE
- if [ $# -eq 1 -a "$1" = "--stdin" ] ; then
+ if [ $# -eq 1 ] && [ "$1" = "--stdin" ] ; then
cat >&61
else
echo "$@" >&61
===================================================================
RCS file: examples/functions/csh-compat,v
retrieving revision 2.5.2.0
retrieving revision 2.5.2.1
diff -pu -r2.5.2.0 -r2.5.2.1
--- examples/functions/csh-compat 1996/07/18 21:17:10 2.5.2.0
+++ examples/functions/csh-compat 2002/07/24 08:08:42 2.5.2.1
@@ -33,15 +33,16 @@ function alias ()
then
declare -f $1
else
- echo $2 | egrep -s '(\!|#)' 2>/dev/null
- if [ $? -eq 0 ]
- then
+ case $2 in
+ *[#\!]*)
comm=$(echo $2 | sed 's/\\!\*/\"$\@\"/g
s/\\!:\([1-9]\)/\"$\1\"/g
s/#/\\#/g')
- else
+ ;;
+ *)
comm="$2 \"\$@\""
- fi
+ ;;
+ esac
eval function $1 \(\) "{" command "$comm" "; }"
fi
}
===================================================================
RCS file: examples/functions/exitstat,v
retrieving revision 2.5.2.0
retrieving revision 2.5.2.1
diff -pu -r2.5.2.0 -r2.5.2.1
--- examples/functions/exitstat 1995/05/19 19:12:35 2.5.2.0
+++ examples/functions/exitstat 2002/07/24 08:08:42 2.5.2.1
@@ -8,7 +8,7 @@ function check_exit_status ()
local status="$?"
local signal=""
- if [ ${status} -ne 0 -a ${status} != 128 ]; then
+ if [ ${status} -ne 0 ] && [ ${status} != 128 ]; then
# If process exited by a signal, determine name of signal.
if [ ${status} -gt 128 ]; then
signal="$(builtin kill -l $((${status} - 128)) 2>/dev/null)"
===================================================================
RCS file: examples/functions/getoptx.bash,v
retrieving revision 2.5.2.0
retrieving revision 2.5.2.1
diff -pu -r2.5.2.0 -r2.5.2.1
--- examples/functions/getoptx.bash 1998/02/06 20:46:36 2.5.2.0
+++ examples/functions/getoptx.bash 2002/07/24 08:08:42 2.5.2.1
@@ -134,7 +134,7 @@ function getoptex()
let OPTIND || OPTIND=1
[ $OPTIND -lt $# ] || return 1
shift $OPTIND
- if [ "$1" != "-" -a "$1" != "${1#-}" ]
+ if [ "$1" != "-" ] && [ "$1" != "${1#-}" ]
then OPTIND=$[OPTIND+1]; if [ "$1" != "--" ]
then
local o
===================================================================
RCS file: examples/functions/kshenv,v
retrieving revision 2.5.2.0
retrieving revision 2.5.2.1
diff -pu -r2.5.2.0 -r2.5.2.1
--- examples/functions/kshenv 2001/02/23 16:53:29 2.5.2.0
+++ examples/functions/kshenv 2002/07/24 08:08:42 2.5.2.1
@@ -207,7 +207,7 @@ substring ()
;;
esac
# test for too few or too many arguments
- if [ x"$1" = x -o $# -gt 2 ]; then
+ if [ x"$1" = x ] || [ $# -gt 2 ]; then
print -u2 'substring: bad argument count'
return 1
fi
===================================================================
RCS file: examples/functions/manpage,v
retrieving revision 2.5.2.0
retrieving revision 2.5.2.1
diff -pu -r2.5.2.0 -r2.5.2.1
--- examples/functions/manpage 2002/04/04 15:23:10 2.5.2.0
+++ examples/functions/manpage 2002/07/24 08:08:42 2.5.2.1
@@ -70,7 +70,7 @@ function whatis ()
function apropos ()
{
- whatis_internal "$1" "fgrep"
+ whatis_internal "$1" "grep -F"
}
# Note: "-" and "-t" together not supported. This man could be
@@ -102,7 +102,7 @@ function man ()
g="grep -w"
a=$(basename "$2")
else
- g=fgrep
+ g="grep -F"
a="$2"
fi
whatis_internal "$a" "$g"
===================================================================
RCS file: examples/functions/recurse,v
retrieving revision 2.5.2.0
retrieving revision 2.5.2.1
diff -pu -r2.5.2.0 -r2.5.2.1
--- examples/functions/recurse 2000/11/21 16:24:05 2.5.2.0
+++ examples/functions/recurse 2002/07/24 08:08:42 2.5.2.1
@@ -44,15 +44,15 @@ function recurse
if cd "$1" ; then
for file in $2; do
- if [ -f "$file" -o -d "$file" ]; then
+ if [ -f "$file" ] || [ -d "$file" ]; then
eval "$3"
fi
done
for file in .* * ; do
- if [ "$file" = "." -o "$file" = ".." ] ; then
+ if [ "$file" = "." ] || [ "$file" = ".." ] ; then
continue
fi
- if [ -d "$file" -a ! -L "$file" ]; then
+ if [ -d "$file" ] && [ ! -L "$file" ]; then
recurse "$file" "$2" "$3" "$path"
fi
done
===================================================================
RCS file: examples/functions/substr,v
retrieving revision 2.5.2.0
retrieving revision 2.5.2.1
diff -pu -r2.5.2.0 -r2.5.2.1
--- examples/functions/substr 1991/02/28 01:58:40 2.5.2.0
+++ examples/functions/substr 2002/07/24 08:08:42 2.5.2.1
@@ -30,7 +30,7 @@ substr()
;;
esac
- if [ "$#" -eq 0 -o "$#" -gt 2 ] ; then
+ if [ "$#" -eq 0 ] || [ "$#" -gt 2 ] ; then
echo "substr: bad argument count"
return 2
fi
===================================================================
RCS file: examples/functions/substr2,v
retrieving revision 2.5.2.0
retrieving revision 2.5.2.1
diff -pu -r2.5.2.0 -r2.5.2.1
--- examples/functions/substr2 1991/02/28 01:58:42 2.5.2.0
+++ examples/functions/substr2 2002/07/24 08:08:42 2.5.2.1
@@ -32,7 +32,7 @@ substr()
shift $[ $OPTIND -1 ]
fi
- if [ "$#" -eq 0 -o "$#" -gt 2 ] ; then
+ if [ "$#" -eq 0 ] || [ "$#" -gt 2 ] ; then
echo "substr: bad argument count"
return 2
fi
===================================================================
RCS file: examples/functions/xalias.bash,v
retrieving revision 2.5.2.0
retrieving revision 2.5.2.1
diff -pu -r2.5.2.0 -r2.5.2.1
--- examples/functions/xalias.bash 1996/03/14 20:39:06 2.5.2.0
+++ examples/functions/xalias.bash 2002/07/24 08:08:42 2.5.2.1
@@ -7,15 +7,16 @@ function xalias ()
then
declare -f $1
else
- echo $2 | egrep -q '(\!|#)'
- if [ $? -eq 0 ]
- then
+ case $2 in
+ *[#\!]*)
comm=$(echo $2 | sed 's/\\!\*/\"$\@\"/g
s/\\!:\([1-9]\)/\"$\1\"/g
s/#/\\#/g')
- else
+ ;;
+ *)
comm="$2 \"\$@\""
- fi
+ ;;
+ esac
eval function $1 \(\) "{" command "$comm" "; }"
fi
}
===================================================================
RCS file: examples/functions/xfind.bash,v
retrieving revision 2.5.2.0
retrieving revision 2.5.2.1
diff -pu -r2.5.2.0 -r2.5.2.1
--- examples/functions/xfind.bash 1999/04/30 13:59:19 2.5.2.0
+++ examples/functions/xfind.bash 2002/07/24 08:08:42 2.5.2.1
@@ -39,7 +39,7 @@ xfind()
# and directories that start with a period.
for x in * ; do
- if [ -d "$x" -a ! -L "$x" ] ; then
+ if [ -d "$x" ] && [ ! -L "$x" ] ; then
$FUNCNAME "$x" "$2" "$action"
fi
done
===================================================================
RCS file: examples/misc/aliasconv.bash,v
retrieving revision 2.5.2.0
retrieving revision 2.5.2.1
diff -pu -r2.5.2.0 -r2.5.2.1
--- examples/misc/aliasconv.bash 1998/11/23 20:05:16 2.5.2.0
+++ examples/misc/aliasconv.bash 2002/07/24 08:08:42 2.5.2.1
@@ -14,16 +14,20 @@ T=$'\t'
cat << \EOF >/tmp/cb$$.1
mkalias ()
{
- if [ "x$2" = "x" ]; then
+ case $2 in
+ '')
echo alias ${1}="''"
- elif echo "$2" | egrep -s '(\!|#)' >/dev/null 2>&1; then
+ ;;
+ *[#\!]*)
comm=$(echo $2 | sed 's/\!\*/"$\@"/g
s/\!:\([1-9]\)/"$\1"/g
s/#/\#/g')
echo $1 \(\) "{" command "$comm" "; }"
- else
+ ;;
+ *)
echo alias ${1}=\'$(echo "${2}" | sed "s:':'\\\\'':")\'
- fi
+ ;;
+ esac
}
EOF
===================================================================
RCS file: examples/misc/aliasconv.sh,v
retrieving revision 2.5.2.0
retrieving revision 2.5.2.1
diff -pu -r2.5.2.0 -r2.5.2.1
--- examples/misc/aliasconv.sh 1998/11/23 20:05:24 2.5.2.0
+++ examples/misc/aliasconv.sh 2002/07/24 08:08:42 2.5.2.1
@@ -14,16 +14,20 @@ T=' '
cat << \EOF >/tmp/cb$$.1
mkalias ()
{
- if [ "x$2" = "x" ]; then
+ case $2 in
+ '')
echo alias ${1}="''"
- elif echo "$2" | egrep -s '(\!|#)' >/dev/null 2>&1; then
+ ;;
+ *[#\!]*)
comm=`echo $2 | sed 's/\\!\*/"$\@"/g
s/\\!:\([1-9]\)/"$\1"/g
s/#/\#/g'`
echo $1 \(\) "{" command "$comm" "; }"
- else
+ ;;
+ *)
echo alias ${1}=\'`echo "${2}" | sed "s:':'\\\\\\\\'':"`\'
- fi
+ ;;
+ esac
}
EOF
===================================================================
RCS file: examples/misc/cshtobash,v
retrieving revision 2.5.2.0
retrieving revision 2.5.2.1
diff -pu -r2.5.2.0 -r2.5.2.1
--- examples/misc/cshtobash 1996/07/19 18:46:50 2.5.2.0
+++ examples/misc/cshtobash 2002/07/24 08:08:42 2.5.2.1
@@ -36,16 +36,20 @@ EOF
cat << \EOF >/tmp/cb$$.1
mkalias ()
{
- if [ -z "$2" ]; then
+ case $2 in
+ '')
echo alias ${1}="''"
- elif echo "$2" | egrep -s '(\!|#)' >/dev/null 2>&1; then
+ ;;
+ *[#\!]*)
comm=$(echo $2 | sed 's/\!\*/"$\@"/g
s/\!:\([1-9]\)/"$\1"/g
s/#/\#/g')
echo $1 \(\) "{" command "$comm" "; }"
- else
+ ;;
+ *)
echo alias ${1}=\'$(echo "${2}" | sed "s:':'\\\\'':")\'
- fi
+ ;;
+ esac
}
EOF
===================================================================
RCS file: examples/obashdb/bashdb.fns,v
retrieving revision 2.5.2.0
retrieving revision 2.5.2.1
diff -pu -r2.5.2.0 -r2.5.2.1
--- examples/obashdb/bashdb.fns 1997/01/22 17:43:48 2.5.2.0
+++ examples/obashdb/bashdb.fns 2002/07/24 08:08:42 2.5.2.1
@@ -88,7 +88,7 @@ _at_linenumbp() {
if [ -z "${_linebp}" ]; then
return 1
fi
- echo "${_curline}" | egrep "(${_linebp%\|})" >/dev/null 2>&1
+ echo "${_curline}" | grep -E "${_linebp%\|}" >/dev/null 2>&1
return $?
}
@@ -101,7 +101,7 @@ _at_stringbp() {
return 1;
fi
l=${_lines[$_curline-$_firstline+1]}
- echo "${l}" | egrep "*(${_stringbp%\|})*" >/dev/null 2>&1
+ echo "${l}" | grep -E "\\*(${_stringbp%\|})\\*" >/dev/null 2>&1
return $?
}
===================================================================
RCS file: examples/scripts.noah/number.bash,v
retrieving revision 2.5.2.0
retrieving revision 2.5.2.1
diff -pu -r2.5.2.0 -r2.5.2.1
--- examples/scripts.noah/number.bash 1995/05/25 15:32:02 2.5.2.0
+++ examples/scripts.noah/number.bash 2002/07/24 08:08:42 2.5.2.1
@@ -108,7 +108,7 @@ function number ()
;;
0 ) : ;;
* )
- if test ".${val2}" != '.' -a ".${d1}" != '.0' ; then
+ if test ".${val2}" != '.' && test ".${d1}" != '.0' ; then
val2="${val2}-"
fi
case "${d1}" in
===================================================================
RCS file: examples/scripts.noah/string.bash,v
retrieving revision 2.5.2.0
retrieving revision 2.5.2.1
diff -pu -r2.5.2.0 -r2.5.2.1
--- examples/scripts.noah/string.bash 1995/05/25 18:36:15 2.5.2.0
+++ examples/scripts.noah/string.bash 2002/07/24 08:08:42 2.5.2.1
@@ -95,11 +95,11 @@ function strcmp ()
###;;;autoload
function strncmp ()
{
- if [ -z "${3}" -o "${3}" -le "0" ]; then
+ if [ -z "${3}" ] || [ "${3}" -le "0" ]; then
return 0
fi
- if [ ${3} -ge ${#1} -a ${3} -ge ${#2} ]; then
+ if [ ${3} -ge ${#1} ] && [ ${3} -ge ${#2} ]; then
strcmp "$1" "$2"
return $?
else
===================================================================
RCS file: examples/scripts.v2/cdhist.bash,v
retrieving revision 2.5.2.0
retrieving revision 2.5.2.1
diff -pu -r2.5.2.0 -r2.5.2.1
--- examples/scripts.v2/cdhist.bash 1996/10/16 19:54:20 2.5.2.0
+++ examples/scripts.v2/cdhist.bash 2002/07/24 08:08:42 2.5.2.1
@@ -39,7 +39,7 @@ cd()
set -- $HOME
fi
- if [ "$CDHISTFILE" -a -r "$CDHISTFILE" ] # if directory history exists
+ if [ "$CDHISTFILE" ] && [ -r "$CDHISTFILE" ] # if directory history
exists
then
typeset CDHIST
i=-1
@@ -49,7 +49,7 @@ cd()
done <$CDHISTFILE
fi
- if [ "${CDHIST[0]}" != "$PWD" -a "$PWD" != "" ]
+ if [ "${CDHIST[0]}" != "$PWD" ] && [ "$PWD" != "" ]
then
_cdins # insert $PWD into cd history
fi
===================================================================
RCS file: examples/scripts.v2/fman,v
retrieving revision 2.5.2.0
retrieving revision 2.5.2.1
diff -pu -r2.5.2.0 -r2.5.2.1
--- examples/scripts.v2/fman 1995/05/10 20:08:18 2.5.2.0
+++ examples/scripts.v2/fman 2002/07/24 08:08:42 2.5.2.1
@@ -56,13 +56,13 @@ FindSectionsInIndex ()
fi
done
[ -z "$indexes" ] && return
- # Make egrep give filename
+ # Make grep give filename
[ NIndex -lt 2 ] && indexes="$indexes /dev/null"
# set positional parameters to
# indexfile:searchname pagename section ...
# e.g.
# /usr/man/index:FP_OFF Routines DOS
- set -- `egrep "^$page[ ]" $indexes`
+ set -- `grep "^$page[ ]" $indexes`
while [ $# -gt 2 ]; do
FileNames[i]=${1%%index*}cat$3/$2.$3
Sections[i]=$3
===================================================================
RCS file: examples/scripts.v2/frcp,v
retrieving revision 2.5.2.0
retrieving revision 2.5.2.1
diff -pu -r2.5.2.0 -r2.5.2.1
--- examples/scripts.v2/frcp 1995/05/09 16:41:31 2.5.2.0
+++ examples/scripts.v2/frcp 2002/07/24 08:08:42 2.5.2.1
@@ -110,7 +110,7 @@ function CopyFiles {
*/) ;; # don't add / if trailing / already present
*) if [ $# -gt 2 ] || # if more than two args given, last must be a dir
# If dest in on local machine, check whether it is a directory
- [ $DestMach = $LocalMach -a -d $DestPath ] ||
+ { [ $DestMach = $LocalMach ] && [ -d $DestPath ]; } ||
# If dest ends with . or .., it is a directory
lastisdot "$DestPath"
then
===================================================================
RCS file: examples/scripts.v2/repeat,v
retrieving revision 2.5.2.0
retrieving revision 2.5.2.1
diff -pu -r2.5.2.0 -r2.5.2.1
--- examples/scripts.v2/repeat 1998/06/29 14:45:15 2.5.2.0
+++ examples/scripts.v2/repeat 2002/07/24 08:08:42 2.5.2.1
@@ -103,7 +103,7 @@ esac
shift
-[ -z "$end" -o $count -le "$end" ] && increment=1 || increment=-1
+[ -z "$end" ] || [ $count -le "$end" ] && increment=1 || increment=-1
istrue $verbose && echo "start=$count end=$end" 1>&2
===================================================================
RCS file: examples/scripts.v2/vtree,v
retrieving revision 2.5.2.0
retrieving revision 2.5.2.1
diff -pu -r2.5.2.0 -r2.5.2.1
--- examples/scripts.v2/vtree 1995/05/10 21:36:03 2.5.2.0
+++ examples/scripts.v2/vtree 2002/07/24 08:08:42 2.5.2.1
@@ -38,7 +38,7 @@ for i in "$@"; do
vars="$vars $i"
;;
*)
- if [ ! -x $i -o ! -d $i ]; then # arg must be a dir and executable
+ if [ ! -x $i ] || [ ! -d $i ]; then # arg must be a dir and
executable
echo "$i: directory not accessible."
exit
fi
===================================================================
RCS file: examples/scripts/adventure.sh,v
retrieving revision 2.5.2.0
retrieving revision 2.5.2.1
diff -pu -r2.5.2.0 -r2.5.2.1
--- examples/scripts/adventure.sh 2000/06/12 20:49:33 2.5.2.0
+++ examples/scripts/adventure.sh 2002/07/24 08:08:42 2.5.2.1
@@ -86,8 +86,8 @@ export PATH
trap 'echo Ouch!' 2 3
#trap '' 18 # disable Berkeley job control
-#ash_lk(){ echo " $1 " | fgrep " $2 " >&- 2>&-; }
-ash_lk(){ echo " $1 " | fgrep -q " $2 " >/dev/null 2>&1 ; }
+#ash_lk(){ echo " $1 " | grep -F " $2 " >&- 2>&-; }
+ash_lk(){ echo " $1 " | grep -Fq " $2 " >/dev/null 2>&1 ; }
ash_pr(){ echo $* | tr ' ' '\012' | pr -5 -t -w75 -l$[ ( $# + 4 ) / 5 ]; }
ash_rm(){ echo " $1 " | sed -e "s/ $2 / /" -e 's/^ //' -e 's/ $//'; }
===================================================================
RCS file: examples/scripts/bcsh.sh,v
retrieving revision 2.5.2.0
retrieving revision 2.5.2.1
diff -pu -r2.5.2.0 -r2.5.2.1
--- examples/scripts/bcsh.sh 2002/04/04 15:25:40 2.5.2.0
+++ examples/scripts/bcsh.sh 2002/07/24 08:08:42 2.5.2.1
@@ -389,7 +389,7 @@ esac
trap ':' 2
trap exit 3
-trap "tail -$savehist $histfile>/tmp/hist$$;uniq /tmp/hist$$ > $histfile;\
+trap "tail -n $savehist $histfile>/tmp/hist$$;uniq /tmp/hist$$ > $histfile;\
rm -f /tmp/*$$;exit 0" 15
getcmd=yes
@@ -517,7 +517,7 @@ do
esac
cmd="${cmd};$line"
- while test "$line" != "done" -a "$line" != "end"
+ while test "$line" != "done" && test "$line" != "end"
do
echo $n "$PS2$c"
read line
@@ -531,7 +531,7 @@ do
echo "$cmd" > /tmp/bcsh$$
;;
if[\ \ ]*)
- while test "$line" != "fi" -a "$line" != "endif"
+ while test "$line" != "fi" && test "$line" != "endif"
do
echo $n "$PS2$c"
read line
@@ -659,7 +659,7 @@ esac/
-[0-9]*)
wanted="`expr \"$i\" :
'-\([0-9][0-9]*\).*'`"
rest="`expr \"$i\" :
'-[0-9][0-9]*\(.*\)'`"
- i="`tail -$wanted $histfile | sed -e
"1q"`"
+ i="`tail -n $wanted $histfile | sed -e
"1q"`"
;;
esac
;;
@@ -917,14 +917,14 @@ esac/
continue
;;
exec[\ \ ]*)
- tail -$savehist $histfile>/tmp/hist$$
+ tail -n $savehist $histfile>/tmp/hist$$
uniq /tmp/hist$$ > $histfile
rm -f /tmp/*$$
echo $cmd > /tmp/cmd$$
. /tmp/cmd$$
;;
login[\ \ ]*|newgrp[\ \ ]*)
- tail -$savehist $histfile>/tmp/hist$$
+ tail -n $savehist $histfile>/tmp/hist$$
uniq /tmp/hist$$ > $histfile
rm -f /tmp/*$$
echo $cmd > /tmp/cmd$$
@@ -936,22 +936,22 @@ esac/
# sh $logoutfile
$SHELL $logoutfile
fi
- tail -$savehist $histfile > /tmp/hist$$
+ tail -n $savehist $histfile > /tmp/hist$$
uniq /tmp/hist$$ > $histfile
rm -f /tmp/*$$
exit 0
;;
h|history)
- grep -n . $histfile | tail -$history | sed -e 's@:@ @' |
$PAGER
+ grep -n . $histfile | tail -n $history | sed -e 's@:@ @' |
$PAGER
continue
;;
h[\ \ ]\|*|h[\ \ ]\>*|h\|*|h\>*)
- cmd="`echo \"$cmd\" | sed -e \"s@h@grep -n . $histfile | tail
-$history | sed -e 's@:@ @'@\"`"
+ cmd="`echo \"$cmd\" | sed -e \"s@h@grep -n . $histfile | tail
-n $history | sed -e 's@:@ @'@\"`"
getcmd=no
continue
;;
history[\ \ ]*\|*|history[\ \ ]*\>*)
- cmd="`echo \"$cmd\" | sed -e \"s@history@grep -n . $histfile |
tail -$history | sed -e 's@:@ @'@\"`"
+ cmd="`echo \"$cmd\" | sed -e \"s@history@grep -n . $histfile |
tail -n $history | sed -e 's@:@ @'@\"`"
getcmd=no
continue
;;
===================================================================
RCS file: examples/scripts/fixfiles.bash,v
retrieving revision 2.5.2.0
retrieving revision 2.5.2.1
diff -pu -r2.5.2.0 -r2.5.2.1
--- examples/scripts/fixfiles.bash 1997/09/04 18:44:06 2.5.2.0
+++ examples/scripts/fixfiles.bash 2002/07/24 08:08:42 2.5.2.1
@@ -62,7 +62,7 @@ processdir()
set +f
for file in * ; do
set -f
- if [ "$file" != "." -a "$file" != ".." ] ; then
+ if [ "$file" != "." ] && [ "$file" != ".." ] ; then
if [ -L "$file" ] ; then
echo "skipping symlink" $file in `pwd`
elif [ -d "$file" ] ; then
===================================================================
RCS file: examples/scripts/line-input.bash,v
retrieving revision 2.5.2.0
retrieving revision 2.5.2.1
diff -pu -r2.5.2.0 -r2.5.2.1
--- examples/scripts/line-input.bash 1999/04/30 13:32:44 2.5.2.0
+++ examples/scripts/line-input.bash 2002/07/24 08:08:42 2.5.2.1
@@ -125,11 +125,11 @@ function getline
unset linesave # forget temp var
;;
)
- while [ "${line% }" != "$line" -a ${#line} != 0 ] ; do
+ while [ "${line% }" != "$line" ] && [ ${#line} != 0 ] ;
do
echo -n " "
line="${line%?}"
done
- while [ "${line% }" = "$line" -a ${#line} != 0 ] ; do
+ while [ "${line% }" = "$line" ] && [ ${#line} != 0 ] ;
do
echo -n " "
line="${line%?}"
done
@@ -151,7 +151,7 @@ function getline
# If length is restricted, and the line is too
# long, then beep...
- if [ "$2" != 0 -a $(( ${#line} >= $2 )) = 1 ] ; then
+ if [ "$2" != 0 ] && [ $(( ${#line} >= $2 )) = 1 ] ; then
echo -n
else # Otherwise add
line="$line$key" # the character.
===================================================================
RCS file: examples/startup-files/apple/aliases,v
retrieving revision 2.5.2.0
retrieving revision 2.5.2.1
diff -pu -r2.5.2.0 -r2.5.2.1
--- examples/startup-files/apple/aliases 2002/04/04 15:27:35 2.5.2.0
+++ examples/startup-files/apple/aliases 2002/07/24 08:08:42 2.5.2.1
@@ -22,7 +22,7 @@ alias l='ls -lg'
files () { find ${1} -type f -print ; }
ff () { find . -name ${1} -print ; }
ll () { ls -lag "$@" | more ; }
-word () { fgrep -i "$*" /usr/dict/web2 ; }
+word () { grep -Fi "$*" /usr/dict/web2 ; }
wordcount () { cat "${1}" | tr -s ' .,;:?\!()[]"' '\012' | \
awk 'END {print NR}' ; }
===================================================================
RCS file: support/xenix-link.sh,v
retrieving revision 2.5.2.0
retrieving revision 2.5.2.1
diff -pu -r2.5.2.0 -r2.5.2.1
--- support/xenix-link.sh 2002/04/17 17:28:10 2.5.2.0
+++ support/xenix-link.sh 2002/07/24 08:08:42 2.5.2.1
@@ -36,7 +36,7 @@ rm -f bash
if [ -z "$CC" ]
then
- if [ -f /unix -a ! -f /xenix ]
+ if [ -f /unix ] && [ ! -f /xenix ]
then
CC="cc -xenix"
else
===================================================================
RCS file: tests/array.tests,v
retrieving revision 2.5.2.0
retrieving revision 2.5.2.1
diff -pu -r2.5.2.0 -r2.5.2.1
--- tests/array.tests 2002/03/28 20:50:21 2.5.2.0
+++ tests/array.tests 2002/07/24 08:08:42 2.5.2.1
@@ -3,7 +3,7 @@
set +o posix
set +a
-# The calls to egrep -v are to filter out builtin array variables that are
+# The calls to sed filter out builtin array variables that are
# automatically set and possibly contain values that vary.
# first make sure we handle the basics
@@ -45,7 +45,7 @@ echo ${a[@]}
echo ${a[*]}
# this should print out values, too
-declare -a | egrep -v '(BASH_VERSINFO|PIPESTATUS|GROUPS)'
+declare -a | sed '/BASH_VERSINFO/d; /PIPESTATUS/d; /GROUPS/d'
unset a[7]
echo ${a[*]}
@@ -74,11 +74,11 @@ echo ${a[@]}
readonly a[5]
readonly a
# these two lines should output `declare' commands
-readonly -a | egrep -v '(BASH_VERSINFO|PIPESTATUS|GROUPS)'
-declare -ar | egrep -v '(BASH_VERSINFO|PIPESTATUS|GROUPS)'
+readonly -a | sed '/BASH_VERSINFO/d; /PIPESTATUS/d; /GROUPS/d'
+declare -ar | sed '/BASH_VERSINFO/d; /PIPESTATUS/d; /GROUPS/d'
# this line should output `readonly' commands, even for arrays
set -o posix
-readonly -a | egrep -v '(BASH_VERSINFO|PIPESTATUS|GROUPS)'
+readonly -a | sed '/BASH_VERSINFO/d; /PIPESTATUS/d; /GROUPS/d'
set +o posix
declare -a d='([1]="" [2]="bdef" [5]="hello world" "test")'
@@ -93,7 +93,7 @@ b=([0]=this [1]=is [2]=a [3]=test [4]="$
echo ${b[@]:2:3}
-declare -pa | egrep -v '(BASH_VERSINFO|PIPESTATUS|GROUPS)'
+declare -pa | sed '/BASH_VERSINFO/d; /PIPESTATUS/d; /GROUPS/d'
a[3]="this is a test"
@@ -111,7 +111,7 @@ d=([]=abcde [1]="test test" [*]=last [-6
unset d[12]
unset e[*]
-declare -a | egrep -v '(BASH_VERSINFO|PIPESTATUS|GROUPS)'
+declare -a | sed '/BASH_VERSINFO/d; /PIPESTATUS/d; /GROUPS/d'
ps1='hello'
unset ps1[2]
@@ -137,7 +137,7 @@ echo ${vv[0]} ${vv[3]}
echo ${vv[@]}
unset vv
-declare -a | egrep -v '(BASH_VERSINFO|PIPESTATUS|GROUPS)'
+declare -a | sed '/BASH_VERSINFO/d; /PIPESTATUS/d; /GROUPS/d'
export rv
#set
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- bash 2.05b port to POSIX 1003.1-2001 hosts,
Paul Eggert <=