diff options
author | Roger A. Faulkner <Roger.Faulkner@Oracle.COM> | 2010-04-03 09:48:44 -0700 |
---|---|---|
committer | Roger A. Faulkner <Roger.Faulkner@Oracle.COM> | 2010-04-03 09:48:44 -0700 |
commit | 3e14f97f673e8a630f076077de35afdd43dc1587 (patch) | |
tree | 9828b6b676f58d7b27dd28e00202d3f3461a5cd8 /usr/src/lib/libshell/common/scripts | |
parent | 4f60987df4dcaa54a88b596f861fbf4f3382c65e (diff) | |
download | illumos-gate-3e14f97f673e8a630f076077de35afdd43dc1587.tar.gz |
6939349 RFE: Update ksh93 to ast-ksh.2010-03-09
6877392 ksh93 regresses 'uniq -c' performance
6887363 Korn shell 93 sometimes mishandles return value of its child process
6900314 (while true ; do true|true ; done) hang in ioctl() with SIGTTOU
6904557 wc no longer counts number of bytes correctly
6904575 cut -d with multibyte character no longer works
6904597 paste -d no longer works with multibyte characters
6904780 /usr/bin/cksum changed output in snv_128
6904870 uniq -s does not skip multibyte characters correctly
6904878 join -t no longer works with multibyte char separator
6907460 EXIT trap handlers are sometimes executed twice
6909579 libast getopt solaris compatibility broken
6920072 ksh93 tail -f, with unconditional .25s sleep and line parsing, about 37x slower than cat
6932124 mktemp in ksh93 is broken
Contributed by Olga Kryzhanovska <olga.kryzhanovska@gmail.com>
Diffstat (limited to 'usr/src/lib/libshell/common/scripts')
24 files changed, 102 insertions, 101 deletions
diff --git a/usr/src/lib/libshell/common/scripts/cpvprint.sh b/usr/src/lib/libshell/common/scripts/cpvprint.sh index bcf2daa985..1257d24876 100644 --- a/usr/src/lib/libshell/common/scripts/cpvprint.sh +++ b/usr/src/lib/libshell/common/scripts/cpvprint.sh @@ -22,8 +22,7 @@ # # -# Copyright 2009 Sun Microsystems, Inc. All rights reserved. -# Use is subject to license terms. +# Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved. # # diff --git a/usr/src/lib/libshell/common/scripts/crawlsrccomments.sh b/usr/src/lib/libshell/common/scripts/crawlsrccomments.sh index bdcecd00cf..bcc6bec0ae 100644 --- a/usr/src/lib/libshell/common/scripts/crawlsrccomments.sh +++ b/usr/src/lib/libshell/common/scripts/crawlsrccomments.sh @@ -22,8 +22,7 @@ # # -# Copyright 2009 Sun Microsystems, Inc. All rights reserved. -# Use is subject to license terms. +# Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved. # # Solaris needs /usr/xpg6/bin:/usr/xpg4/bin because the tools in /usr/bin are not POSIX-conformant @@ -697,8 +696,8 @@ function cat_http_body if [[ "${emode}" == "chunked" ]] ; then while IFS=$'\r' read hexchunksize && - [[ "${hexchunksize}" == ~(Elri)[0-9abcdef]* ]] && - (( chunksize=16#${hexchunksize} )) && (( chunksize > 0 )) ; do + [[ "${hexchunksize}" == ~(Elri)[0-9abcdef]+ ]] && + (( chunksize=$( printf "16#%s\n" "${hexchunksize}" ) )) && (( chunksize > 0 )) ; do dd bs=1 count="${chunksize}" 2>/dev/null done else @@ -764,7 +763,7 @@ function cat_url # send HTTP request request="GET /${path} HTTP/1.1\r\n" request+="Host: ${host}\r\n" - request+="User-Agent: crawlsrccomments/ksh93(ssl) (2009-05-08; $(uname -s -r -p))\r\n" + request+="User-Agent: crawlsrccomments/ksh93(ssl) (2010-03-27; $(uname -s -r -p))\r\n" request+="Connection: close\r\n" print -n -- "${request}\r\n" >> "${sslfifo.in}" @@ -784,7 +783,7 @@ function cat_url # send HTTP request request="GET /${path} HTTP/1.1\r\n" request+="Host: ${host}\r\n" - request+="User-Agent: crawlsrccomments/ksh93 (2009-05-08; $(uname -s -r -p))\r\n" + request+="User-Agent: crawlsrccomments/ksh93 (2010-03-27; $(uname -s -r -p))\r\n" request+="Connection: close\r\n" print -n -- "${request}\r\n" >&${netfd} @@ -1141,8 +1140,9 @@ function usage } typeset -r do_getcomments_usage=$'+ -[-?\n@(#)\$Id: getcomments (Roland Mainz) 2009-05-09 \$\n] +[-?\n@(#)\$Id: getcomments (Roland Mainz) 2010-03-27 \$\n] [-author?Roland Mainz <roland.mainz@sun.com>] +[-author?Roland Mainz <roland.mainz@nrubsig.org>] [+NAME?getcomments - extract license information from source files] [+DESCRIPTION?\bgetcomments\b is a small utilty script which extracts license information from the "\bgetcomments\b"-database @@ -1164,8 +1164,9 @@ typeset -r do_getcomments_usage=$'+ ' typeset -r do_crawl_usage=$'+ -[-?\n@(#)\$Id: crawl (Roland Mainz) 2009-05-09 \$\n] +[-?\n@(#)\$Id: crawl (Roland Mainz) 2010-03-27 \$\n] [-author?Roland Mainz <roland.mainz@sun.com>] +[-author?Roland Mainz <roland.mainz@nrubsig.org>] [+NAME?crawl - crawl comment information from source files] [+DESCRIPTION?\bcrawl\b is a small utilty script which reads a list of source code files from stdin, determinates the type of @@ -1180,8 +1181,9 @@ typeset -r do_crawl_usage=$'+ ' typeset -r crawlsrccomments_usage=$'+ -[-?\n@(#)\$Id: crawlsrccomments (Roland Mainz) 2009-05-09 \$\n] +[-?\n@(#)\$Id: crawlsrccomments (Roland Mainz) 2010-03-27 \$\n] [-author?Roland Mainz <roland.mainz@sun.com>] +[-author?Roland Mainz <roland.mainz@nrubsig.org>] [+NAME?crawlsrccomments - extract and filter comment information from source files] [+DESCRIPTION?\bcrawlsrccomments\b is a small utilty script which reads a list of source code files from stdin, determinates the type of diff --git a/usr/src/lib/libshell/common/scripts/filemutexdemo1.sh b/usr/src/lib/libshell/common/scripts/filemutexdemo1.sh index 1de54a92fc..1d09e4aeb3 100644 --- a/usr/src/lib/libshell/common/scripts/filemutexdemo1.sh +++ b/usr/src/lib/libshell/common/scripts/filemutexdemo1.sh @@ -22,8 +22,7 @@ # # -# Copyright 2008 Sun Microsystems, Inc. All rights reserved. -# Use is subject to license terms. +# Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved. # # diff --git a/usr/src/lib/libshell/common/scripts/filetree1.sh b/usr/src/lib/libshell/common/scripts/filetree1.sh index 243c9758cf..9cbcb0c35d 100644 --- a/usr/src/lib/libshell/common/scripts/filetree1.sh +++ b/usr/src/lib/libshell/common/scripts/filetree1.sh @@ -22,8 +22,7 @@ # # -# Copyright 2008 Sun Microsystems, Inc. All rights reserved. -# Use is subject to license terms. +# Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved. # # Solaris needs /usr/xpg6/bin:/usr/xpg4/bin because the tools in /usr/bin are not POSIX-conformant diff --git a/usr/src/lib/libshell/common/scripts/gnaw.sh b/usr/src/lib/libshell/common/scripts/gnaw.sh index 878f2899ac..25445e7a4d 100644 --- a/usr/src/lib/libshell/common/scripts/gnaw.sh +++ b/usr/src/lib/libshell/common/scripts/gnaw.sh @@ -22,8 +22,7 @@ # # -# Copyright 2009 Sun Microsystems, Inc. All rights reserved. -# Use is subject to license terms. +# Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved. # # diff --git a/usr/src/lib/libshell/common/scripts/mandelbrotset1.sh b/usr/src/lib/libshell/common/scripts/mandelbrotset1.sh index b9ae173df9..082d519abe 100644 --- a/usr/src/lib/libshell/common/scripts/mandelbrotset1.sh +++ b/usr/src/lib/libshell/common/scripts/mandelbrotset1.sh @@ -22,8 +22,7 @@ # # -# Copyright 2009 Sun Microsystems, Inc. All rights reserved. -# Use is subject to license terms. +# Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved. # # @@ -221,14 +220,17 @@ typeset symbollist=' .:0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQR typeset symbollistlen=$(( ${#symbollist} - 1)) typeset mode="parallel" -max_mag=400 -stepwidth=0.1 -numcpus=16 +(( max_mag=400 )) +(( stepwidth=0.1 )) + +# calculate number of worker CPUs and use 3 as fallback +(( numcpus=$(getconf NPROCESSORS_ONLN || print "3") )) +(( numcpus=numcpus*4 )) (( m_width=termsize.columns-1 , m_height=termsize.lines-2 )) typeset -r mandelbrotset1_usage=$'+ -[-?\n@(#)\$Id: mandelbrotset1 (Roland Mainz) 2009-06-14 \$\n] +[-?\n@(#)\$Id: mandelbrotset1 (Roland Mainz) 2010-03-31 \$\n] [-author?Roland Mainz <roland.mainz@nrubsig.org>] [+NAME?mandelbrotset1 - generate mandelbrot set fractals with ksh93] [+DESCRIPTION?\bmandelbrotset1\b mandelbrot set fractal generator diff --git a/usr/src/lib/libshell/common/scripts/multifollow.sh b/usr/src/lib/libshell/common/scripts/multifollow.sh index b5d5cb7bb2..a14d34ee97 100644 --- a/usr/src/lib/libshell/common/scripts/multifollow.sh +++ b/usr/src/lib/libshell/common/scripts/multifollow.sh @@ -22,8 +22,7 @@ # # -# Copyright 2009 Sun Microsystems, Inc. All rights reserved. -# Use is subject to license terms. +# Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved. # # Solaris needs /usr/xpg6/bin:/usr/xpg4/bin because the tools in /usr/bin are not POSIX-conformant diff --git a/usr/src/lib/libshell/common/scripts/numtree1.sh b/usr/src/lib/libshell/common/scripts/numtree1.sh index beca4aae76..ba7783e91e 100644 --- a/usr/src/lib/libshell/common/scripts/numtree1.sh +++ b/usr/src/lib/libshell/common/scripts/numtree1.sh @@ -22,8 +22,7 @@ # # -# Copyright 2009 Sun Microsystems, Inc. All rights reserved. -# Use is subject to license terms. +# Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved. # # @@ -60,10 +59,14 @@ function add_number_to_tree integer i typeset nodepath # full name of compound variable integer -a pe # path elements + integer len + typeset revnums="$(rev <<<"${num}")" # first built an array containing the names of each path element # (e.g. "135" results in an array containing "( 1 3 5 )") - for (( i=$(rev <<<$num) ; i > 0 ; i=i/10 )) ; do + # 10#<number> is used to prevent leading zeros being interpreted + # as octals + for (( len=${#revnums} , i=$( printf "10#%s\n" "${revnums}" ) ; len > 0 ; len--, i=i/10 )) ; do pe+=( $((i % 10)) ) done @@ -72,15 +75,30 @@ function add_number_to_tree nodepath="${treename}" for (( i=0 ; i < ${#pe[@]} ; i++ )) ; do nameref x="${nodepath}" - [[ ! -v x.node ]] && compound -C -a x.nodes - + + # [[ -v ]] does not work for arrays because [[ -v ar ]] + # is equal to [[ -v ar[0] ]]. In this case we can + # use the output of typeset +p x.nodes + [[ "${ typeset +p x.nodes ;}" == "" ]] && compound -a x.nodes + nodepath+=".nodes[${pe[i]}]" done - # insert element + # insert element (leaf) nameref node="${nodepath}" - [[ ! -v node.elements ]] && integer -a node.elements + [[ "${ typeset +p node.elements ;}" == "" ]] && integer -a node.elements node.elements+=( ${num} ) + + # DEBUG only + [[ "${!node.elements[*]}" != "" ]] || fatal_error "assertion $LINENO FAILED" + [[ "${ typeset +p node.elements ;}" == *-a* ]] || fatal_error "assertion $LINENO FAILED" + [[ "${ typeset +p node.elements ;}" == *-i* ]] || fatal_error "assertion $LINENO FAILED" + [[ -v node ]] || fatal_error "assertion $LINENO FAILED" + [[ -R node ]] || fatal_error "assertion $LINENO FAILED" + [[ "${ typeset +p ${!node} ;}" == *-C* ]] || fatal_error "assertion $LINENO FAILED" + [[ "${!x.nodes[*]}" != "" ]] || fatal_error "assertion $LINENO FAILED" + [[ "${ typeset +p x.nodes ;}" == *-a* ]] || fatal_error "assertion $LINENO FAILED" + [[ "${ typeset +p x.nodes ;}" == *-C* ]] || fatal_error "assertion $LINENO FAILED" return 0 } @@ -147,7 +165,7 @@ integer i typeset progname="${ basename "${0}" ; }" typeset -r numtree1_usage=$'+ -[-?\n@(#)\$Id: numtree1 (Roland Mainz) 2009-08-17 \$\n] +[-?\n@(#)\$Id: numtree1 (Roland Mainz) 2010-03-27 \$\n] [-author?Roland Mainz <roland.mainz@nrubsig.org>] [+NAME?numtree1 - generate sorted variable tree containing numbers] [+DESCRIPTION?\bnumtree1\b is a simple variable tree generator diff --git a/usr/src/lib/libshell/common/scripts/primenumbers1.sh b/usr/src/lib/libshell/common/scripts/primenumbers1.sh index aba6f5aeac..b408eb3049 100644 --- a/usr/src/lib/libshell/common/scripts/primenumbers1.sh +++ b/usr/src/lib/libshell/common/scripts/primenumbers1.sh @@ -22,8 +22,7 @@ # # -# Copyright 2008 Sun Microsystems, Inc. All rights reserved. -# Use is subject to license terms. +# Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved. # # diff --git a/usr/src/lib/libshell/common/scripts/rssread.sh b/usr/src/lib/libshell/common/scripts/rssread.sh index 1010a7d873..05e703ac2c 100644 --- a/usr/src/lib/libshell/common/scripts/rssread.sh +++ b/usr/src/lib/libshell/common/scripts/rssread.sh @@ -22,8 +22,7 @@ # # -# Copyright 2009 Sun Microsystems, Inc. All rights reserved. -# Use is subject to license terms. +# Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved. # # @@ -124,7 +123,7 @@ typeset -T urlconnection_t=( hexchunksize="${hexchunksize//$'\r'/}" [[ "${hexchunksize}" != "" ]] || continue [[ "${hexchunksize}" == ~(Elri)[0-9abcdef]+ ]] || break - (( chunksize=16#${hexchunksize} )) + (( chunksize=$( printf "16#%s\n" "${hexchunksize}" ) )) (( chunksize > 0 )) || break dd bs=1 count="${chunksize}" 2>/dev/null done @@ -178,7 +177,7 @@ typeset -T urlconnection_t=( function open_connection { if [[ "${_.protocol}" == "https" ]] ; then - _.ssl.fifo.dir="$(mktemp -d)" + _.ssl.fifo.dir="$(mktemp -t -d)" _.ssl.fifo.in="${_.ssl.fifo.dir}/in" _.ssl.fifo.out="${_.ssl.fifo.dir}/out" @@ -244,7 +243,7 @@ typeset -T urlconnection_t=( [[ "${_.host}" != "" ]] || { print -u2 -f "%s: host not set.\n" "$0" ; return 1 ; } [[ "${_.path}" != "" ]] || { print -u2 -f "%s: path not set.\n" "$0" ; return 1 ; } - _.open_connection + _.open_connection || return 1 # send HTTP request request="GET /${_.path} HTTP/1.1\r\n" @@ -563,7 +562,7 @@ function do_rssread set -o errexit urlconnection_t hc - hc.user_agent="rssread/ksh93(ssl) (2009-08-14; $(uname -s -r -p))" + hc.user_agent="rssread/ksh93(ssl) (2010-03-27; $(uname -s -r -p))" hc.init_url "$1" # need extra newline after cat_url to terminate line with $'\n' @@ -609,12 +608,6 @@ typeset -A bookmark_urls # "ramdom" urls for testing bookmark_urls=( ["google_blogs_ksh"]="http://blogsearch.google.com/blogsearch_feeds?hl=en&scoring=d&q=(%22ksh93%22%7C%22ksh+93%22+%7C+%22korn93%22+%7C+%22korn+93%22)&ie=utf-8&num=100&output=rss" - # OpenSolaris.org sites - ["ksh93_integration"]="http://www.opensolaris.org/rss/os/project/ksh93-integration/announcements/rss2.xml" - ["ksh93_integration_ssl"]="https://www.opensolaris.org/rss/os/project/ksh93-integration/announcements/rss2.xml" - ["shell"]="http://www.opensolaris.org/rss/os/project/shell/announcements/rss2.xml" - ["systemz"]="http://www.opensolaris.org/rss/os/project/systemz/announcements/rss2.xml" - ["systemz_ssl"]="https://www.opensolaris.org/rss/os/project/systemz/announcements/rss2.xml" # some Sun staff/sites ["blogs_sun_com"]="http://blogs.sun.com/main/feed/entries/rss" ["bigadmin"]="http://www.sun.com/bigadmin/content/rss/motd.xml" @@ -634,7 +627,7 @@ bookmark_urls=( typeset progname="${ basename "${0}" ; }" typeset -r rssread_usage=$'+ -[-?\n@(#)\$Id: rssread (Roland Mainz) 2009-08-14 \$\n] +[-?\n@(#)\$Id: rssread (Roland Mainz) 2010-03-27 \$\n] [-author?Roland Mainz <roland.mainz@sun.com>] [-author?Roland Mainz <roland.mainz@nrubsig.org>] [+NAME?rssread - fetch RSS messages and convert them to plain text] diff --git a/usr/src/lib/libshell/common/scripts/shcalc.sh b/usr/src/lib/libshell/common/scripts/shcalc.sh index db7149a0bd..50c9317ad4 100644 --- a/usr/src/lib/libshell/common/scripts/shcalc.sh +++ b/usr/src/lib/libshell/common/scripts/shcalc.sh @@ -22,8 +22,7 @@ # # -# Copyright 2008 Sun Microsystems, Inc. All rights reserved. -# Use is subject to license terms. +# Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved. # # diff --git a/usr/src/lib/libshell/common/scripts/shircbot.sh b/usr/src/lib/libshell/common/scripts/shircbot.sh index 3c99355222..82903c53b1 100644 --- a/usr/src/lib/libshell/common/scripts/shircbot.sh +++ b/usr/src/lib/libshell/common/scripts/shircbot.sh @@ -22,8 +22,7 @@ # # -# Copyright 2009 Sun Microsystems, Inc. All rights reserved. -# Use is subject to license terms. +# Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved. # # diff --git a/usr/src/lib/libshell/common/scripts/shlint.sh b/usr/src/lib/libshell/common/scripts/shlint.sh index aea60a4951..7b6b609ac8 100644 --- a/usr/src/lib/libshell/common/scripts/shlint.sh +++ b/usr/src/lib/libshell/common/scripts/shlint.sh @@ -22,8 +22,7 @@ # # -# Copyright 2008 Sun Microsystems, Inc. All rights reserved. -# Use is subject to license terms. +# Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved. # # diff --git a/usr/src/lib/libshell/common/scripts/shman.sh b/usr/src/lib/libshell/common/scripts/shman.sh index 56c2e42c12..1044d6a1bb 100644 --- a/usr/src/lib/libshell/common/scripts/shman.sh +++ b/usr/src/lib/libshell/common/scripts/shman.sh @@ -22,8 +22,7 @@ # # -# Copyright 2009 Sun Microsystems, Inc. All rights reserved. -# Use is subject to license terms. +# Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved. # # Solaris needs /usr/xpg6/bin:/usr/xpg4/bin because the tools in /usr/bin are not POSIX-conformant @@ -150,7 +149,7 @@ function browse_manpage # use "cat" here to avoid that "less" may try funny things cat <"${doc_filename}" | less -I -M $"--prompt=MManual\ page\ ${doc_title}\ ?ltline\ %lt?L/%L.:" else - tmpdirname="$(mktemp -d "/tmp/shman_${PPID}_$$_XXXXXX")" + tmpdirname="$(mktemp -t -d "shman_${PPID}_$$_XXXXXX")" mkdir -p "${tmpdirname}" || { print -u2 -f $"Couldn't create tmp. dir %s\n" "${tmpdirname}" ; return 1 ; } @@ -320,7 +319,7 @@ builtin date typeset progname="$(basename "${0}")" typeset -r man_usage=$'+ -[-?\n@(#)\$Id: shman (Roland Mainz) 2009-06-26 \$\n] +[-?\n@(#)\$Id: shman (Roland Mainz) 2009-12-02 \$\n] [-author?Roland Mainz <roland.mainz@nrubsig.org>] [-author?Roland Mainz <roland.mainz@sun.com>] [+NAME?man - find and display reference manual pages] diff --git a/usr/src/lib/libshell/common/scripts/shnote.sh b/usr/src/lib/libshell/common/scripts/shnote.sh index b449f257c0..217fc7daae 100644 --- a/usr/src/lib/libshell/common/scripts/shnote.sh +++ b/usr/src/lib/libshell/common/scripts/shnote.sh @@ -22,8 +22,7 @@ # # -# Copyright 2009 Sun Microsystems, Inc. All rights reserved. -# Use is subject to license terms. +# Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved. # # Solaris needs /usr/xpg6/bin:/usr/xpg4/bin because the tools in /usr/bin are not POSIX-conformant @@ -125,8 +124,8 @@ function cat_http_body if [[ "${emode}" == "chunked" ]] ; then while IFS=$'\r' read hexchunksize && - [[ "${hexchunksize}" == ~(Elri)[0-9abcdef]* ]] && - (( chunksize=16#${hexchunksize} )) && (( chunksize > 0 )) ; do + [[ "${hexchunksize}" == ~(Elri)[0-9abcdef]+ ]] && + (( chunksize=$( printf "16#%s\n" "${hexchunksize}" ) )) && (( chunksize > 0 )) ; do dd bs=1 count="${chunksize}" 2>/dev/null done else @@ -359,14 +358,14 @@ builtin uname typeset progname="${ basename "${0}" ; }" # HTTP protocol client identifer -typeset -r http_user_agent="shnote/ksh93 (2009-05-09; $(uname -s -r -p))" +typeset -r http_user_agent="shnote/ksh93 (2010-03-27; $(uname -s -r -p))" # name of history log (the number after "history" is some kind of version # counter to handle incompatible changes to the history file format) typeset -r history_file="${HOME}/.shnote/history0.txt" typeset -r shnote_usage=$'+ -[-?\n@(#)\$Id: shnote (Roland Mainz) 2009-05-09 \$\n] +[-?\n@(#)\$Id: shnote (Roland Mainz) 2010-03-27 \$\n] [-author?Roland Mainz <roland.mainz@nrubsig.org>] [+NAME?shnote - read/write text data to internet clipboards] [+DESCRIPTION?\bshnote\b is a small utilty which can read and write text diff --git a/usr/src/lib/libshell/common/scripts/shpiano.sh b/usr/src/lib/libshell/common/scripts/shpiano.sh index e20813a75a..b6d511a6ba 100644 --- a/usr/src/lib/libshell/common/scripts/shpiano.sh +++ b/usr/src/lib/libshell/common/scripts/shpiano.sh @@ -22,8 +22,7 @@ # # -# Copyright 2009 Sun Microsystems, Inc. All rights reserved. -# Use is subject to license terms. +# Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved. # # Solaris needs /usr/xpg6/bin:/usr/xpg4/bin because the tools in /usr/bin are not POSIX-conformant diff --git a/usr/src/lib/libshell/common/scripts/shtinyurl.sh b/usr/src/lib/libshell/common/scripts/shtinyurl.sh index fb18627081..debd28949b 100644 --- a/usr/src/lib/libshell/common/scripts/shtinyurl.sh +++ b/usr/src/lib/libshell/common/scripts/shtinyurl.sh @@ -22,8 +22,7 @@ # # -# Copyright 2009 Sun Microsystems, Inc. All rights reserved. -# Use is subject to license terms. +# Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved. # # Solaris needs /usr/xpg6/bin:/usr/xpg4/bin because the tools in /usr/bin are not POSIX-conformant @@ -93,8 +92,8 @@ function cat_http_body if [[ "${emode}" == "chunked" ]] ; then while IFS=$'\r' read hexchunksize && - [[ "${hexchunksize}" == ~(Elri)[0-9abcdef]* ]] && - (( chunksize=16#${hexchunksize} )) && (( chunksize > 0 )) ; do + [[ "${hexchunksize}" == ~(Elri)[0-9abcdef]+ ]] && + (( chunksize=$( printf "16#%s\n" "${hexchunksize}" ) )) && (( chunksize > 0 )) ; do dd bs=1 count="${chunksize}" 2>/dev/null done else @@ -213,10 +212,10 @@ builtin uname typeset progname="${ basename "${0}" ; }" # HTTP protocol client identifer -typeset -r http_user_agent="shtinyurl/ksh93 (2009-08-12; ${ uname -s -r -p ; })" +typeset -r http_user_agent="shtinyurl/ksh93 (2010-03-27; ${ uname -s -r -p ; })" typeset -r shtinyurl_usage=$'+ -[-?\n@(#)\$Id: shtinyurl (Roland Mainz) 2009-08-12 \$\n] +[-?\n@(#)\$Id: shtinyurl (Roland Mainz) 2010-03-27 \$\n] [-author?Roland Mainz <roland.mainz@nrubsig.org>] [+NAME?shtinyurl - create short alias URL from long URL] [+DESCRIPTION?\bshtinyurl\b is a small utility which passes a given URL diff --git a/usr/src/lib/libshell/common/scripts/shtwitter.sh b/usr/src/lib/libshell/common/scripts/shtwitter.sh index c7672dde6c..217b821e6a 100644 --- a/usr/src/lib/libshell/common/scripts/shtwitter.sh +++ b/usr/src/lib/libshell/common/scripts/shtwitter.sh @@ -22,8 +22,7 @@ # # -# Copyright 2009 Sun Microsystems, Inc. All rights reserved. -# Use is subject to license terms. +# Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved. # # Solaris needs /usr/xpg6/bin:/usr/xpg4/bin because the tools in /usr/bin are not POSIX-conformant @@ -147,8 +146,8 @@ function cat_http_body if [[ "${emode}" == "chunked" ]] ; then while IFS=$'\r' read hexchunksize && - [[ "${hexchunksize}" == ~(Elri)[0-9abcdef]* ]] && - (( chunksize=16#${hexchunksize} )) && (( chunksize > 0 )) ; do + [[ "${hexchunksize}" == ~(Elri)[0-9abcdef]+ ]] && + (( chunksize=$( printf "16#%s\n" "${hexchunksize}" ) )) && (( chunksize > 0 )) ; do dd bs=1 count="${chunksize}" 2>/dev/null done else @@ -313,10 +312,10 @@ builtin uname typeset progname="${ basename "${0}" ; }" # HTTP protocol client identifer -typeset -r http_user_agent="shtwitter/ksh93 (2009-06-15; ${ uname -s -r -p ; })" +typeset -r http_user_agent="shtwitter/ksh93 (2010-03-27; ${ uname -s -r -p ; })" typeset -r shtwitter_usage=$'+ -[-?\n@(#)\$Id: shtwitter (Roland Mainz) 2009-06-15 \$\n] +[-?\n@(#)\$Id: shtwitter (Roland Mainz) 2010-03-27 \$\n] [-author?Roland Mainz <roland.mainz@nrubsig.org>] [+NAME?shtwitter - read/write text data to internet clipboards] [+DESCRIPTION?\bshtwitter\b is a small utility which can read and write text diff --git a/usr/src/lib/libshell/common/scripts/simplefileattributetree1.sh b/usr/src/lib/libshell/common/scripts/simplefileattributetree1.sh index 95a36063dc..a7bc41097e 100644 --- a/usr/src/lib/libshell/common/scripts/simplefileattributetree1.sh +++ b/usr/src/lib/libshell/common/scripts/simplefileattributetree1.sh @@ -22,8 +22,7 @@ # # -# Copyright 2009 Sun Microsystems, Inc. All rights reserved. -# Use is subject to license terms. +# Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved. # # @@ -69,14 +68,18 @@ function add_file_to_tree nodepath="${treename}" for (( i=0 ; i < (${#pe[@]}-1) ; i++ )) ; do nameref x="${nodepath}" - [[ ! -v x.node ]] && compound -A x.nodes + + # [[ -v ]] does not work for arrays because [[ -v ar ]] + # is equal to [[ -v ar[0] ]]. In this case we can + # use the output of typeset +p x.nodes + [[ "${ typeset +p x.nodes ; }" == "" ]] && compound -A x.nodes nodepath+=".nodes[${pe[i]}]" done # insert element nameref node="${nodepath}" - [[ ! -v node.elements ]] && compound -A node.elements + [[ "${ typeset +p node.elements ; }" == "" ]] && compound -A node.elements node.elements[${pe[i]}]=( filepath="${filename}" ) @@ -146,7 +149,7 @@ integer i typeset progname="${ basename "${0}" ; }" typeset -r simplefileattributetree1_usage=$'+ -[-?\n@(#)\$Id: simplefileattributetree1 (Roland Mainz) 2009-06-26 \$\n] +[-?\n@(#)\$Id: simplefileattributetree1 (Roland Mainz) 2010-03-27 \$\n] [-author?Roland Mainz <roland.mainz@nrubsig.org>] [+NAME?simplefileattributetree1 - generate compound variable tree which contains file names and their attributes] [+DESCRIPTION?\bsimplefileattributetree1\b is a simple variable tree diff --git a/usr/src/lib/libshell/common/scripts/simplefiletree1.sh b/usr/src/lib/libshell/common/scripts/simplefiletree1.sh index 5b79aae8f8..d2308394cf 100644 --- a/usr/src/lib/libshell/common/scripts/simplefiletree1.sh +++ b/usr/src/lib/libshell/common/scripts/simplefiletree1.sh @@ -22,8 +22,7 @@ # # -# Copyright 2009 Sun Microsystems, Inc. All rights reserved. -# Use is subject to license terms. +# Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved. # # @@ -68,14 +67,18 @@ function add_file_to_tree nodepath="${treename}" for (( i=0 ; i < (${#pe[@]}-1) ; i++ )) ; do nameref x="${nodepath}" - [[ ! -v x.node ]] && compound -A x.nodes + + # [[ -v ]] does not work for arrays because [[ -v ar ]] + # is equal to [[ -v ar[0] ]]. In this case we can + # use the output of typeset +p x.nodes + [[ "${ typeset +p x.nodes ; }" == "" ]] && compound -A x.nodes nodepath+=".nodes[${pe[i]}]" done # insert element nameref node="${nodepath}" - [[ ! -v node.elements ]] && typeset -a node.elements + [[ "${ typeset +p node.elements ; }" == "" ]] && typeset -a node.elements node.elements+=( "${pe[i]}" ) return 0 diff --git a/usr/src/lib/libshell/common/scripts/svcproptree1.sh b/usr/src/lib/libshell/common/scripts/svcproptree1.sh index d3f1ee9742..60974a361f 100644 --- a/usr/src/lib/libshell/common/scripts/svcproptree1.sh +++ b/usr/src/lib/libshell/common/scripts/svcproptree1.sh @@ -22,8 +22,7 @@ # # -# Copyright 2009 Sun Microsystems, Inc. All rights reserved. -# Use is subject to license terms. +# Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved. # # Solaris needs /usr/xpg6/bin:/usr/xpg4/bin because the tools in /usr/bin are not POSIX-conformant @@ -74,9 +73,7 @@ function svcproptovartree servicename="${servicename/~(El)svc:\//}" # strip "svc:/" propname="${name#~(El).*:properties/}" - if [[ "$(typeset -p "tree[${servicename}].properties")" == "" ]] ; then - compound -A tree[${servicename}].properties - fi + [[ "${ typeset +p "tree[${servicename}].properties" ; }" == "" ]] && compound -A tree[${servicename}].properties nameref node=tree[${servicename}].properties[${propname}] @@ -110,7 +107,7 @@ builtin uname typeset progname="${ basename "${0}" ; }" typeset -r svcproptree1_usage=$'+ -[-?\n@(#)\$Id: svcproptree1 (Roland Mainz) 2009-06-26 \$\n] +[-?\n@(#)\$Id: svcproptree1 (Roland Mainz) 2010-04-02 \$\n] [-author?Roland Mainz <roland.mainz@nrubsig.org>] [+NAME?svcproptree1 - SMF tree demo] [+DESCRIPTION?\bsvcproptree1\b is a small ksh93 compound variable demo diff --git a/usr/src/lib/libshell/common/scripts/termclock.sh b/usr/src/lib/libshell/common/scripts/termclock.sh index 582e70ad62..c1c4cb8092 100644 --- a/usr/src/lib/libshell/common/scripts/termclock.sh +++ b/usr/src/lib/libshell/common/scripts/termclock.sh @@ -22,8 +22,7 @@ # # -# Copyright 2009 Sun Microsystems, Inc. All rights reserved. -# Use is subject to license terms. +# Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved. # # @@ -268,7 +267,7 @@ hours.length=50 hours.scale=12 hours.ch=$"h" float update_interval=0.9 typeset -r termclock_usage=$'+ -[-?\n@(#)\$Id: termclock (Roland Mainz) 2009-05-09 \$\n] +[-?\n@(#)\$Id: termclock (Roland Mainz) 2009-12-02 \$\n] [-author?Roland Mainz <roland.mainz@nrubsig.org>] [-author?David Korn <dgk@research.att.com>] [+NAME?termclock - analog clock for terminals] @@ -295,7 +294,7 @@ which tput >/dev/null || fatal_error $"tput not found." # create temporary file for double-buffering and register an EXIT trap # to remove this file when the shell interpreter exits -scratchfile="${ mktemp "/tmp/termclock.ppid${PPID}_pid$$.XXXXXX" ; }" +scratchfile="${ mktemp -t "termclock.ppid${PPID}_pid$$.XXXXXX" ; }" [[ "${scratchfile}" != "" ]] || fatal_error $"Could not create temporary file name." trap 'rm -f "${scratchfile}"' EXIT rm -f "${scratchfile}" ; redirect 6<> "${scratchfile}" || fatal_error $"Could not create temporary file." diff --git a/usr/src/lib/libshell/common/scripts/test_net_sctp.sh b/usr/src/lib/libshell/common/scripts/test_net_sctp.sh index 92b805f2dd..97de72a9c6 100644 --- a/usr/src/lib/libshell/common/scripts/test_net_sctp.sh +++ b/usr/src/lib/libshell/common/scripts/test_net_sctp.sh @@ -22,8 +22,7 @@ # # -# Copyright 2009 Sun Microsystems, Inc. All rights reserved. -# Use is subject to license terms. +# Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved. # # diff --git a/usr/src/lib/libshell/common/scripts/xmldocumenttree1.sh b/usr/src/lib/libshell/common/scripts/xmldocumenttree1.sh index 9bb25b855a..fe7783b21c 100644 --- a/usr/src/lib/libshell/common/scripts/xmldocumenttree1.sh +++ b/usr/src/lib/libshell/common/scripts/xmldocumenttree1.sh @@ -22,8 +22,7 @@ # # -# Copyright 2009 Sun Microsystems, Inc. All rights reserved. -# Use is subject to license terms. +# Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved. # # Solaris needs /usr/xpg6/bin:/usr/xpg4/bin because the tools in /usr/bin are not POSIX-conformant |