SVN: rc-scripts/trunk: DEVELOPMENT rc.d/init.d/functions rc.d/rc rc.d/rc.sysinit sysconfig/network-s...
glen
glen at pld-linux.org
Thu Mar 19 01:15:25 CET 2009
Author: glen
Date: Thu Mar 19 01:15:25 2009
New Revision: 10218
Modified:
rc-scripts/trunk/DEVELOPMENT
rc-scripts/trunk/rc.d/init.d/functions
rc-scripts/trunk/rc.d/rc
rc-scripts/trunk/rc.d/rc.sysinit
rc-scripts/trunk/sysconfig/network-scripts/functions.network
Log:
- use "local" not "typeset" (compatible with: pdksh/bash/dash)
Modified: rc-scripts/trunk/DEVELOPMENT
==============================================================================
--- rc-scripts/trunk/DEVELOPMENT (original)
+++ rc-scripts/trunk/DEVELOPMENT Thu Mar 19 01:15:25 2009
@@ -7,11 +7,11 @@
mailing list. This is very important.
2)
- use 'typeset' for local variables in functions for example:
+ use 'local' for local variables in functions for example:
function_ble ()
{
-typeset qw er
+local qw er=0
qw=$(tty)
er=/dev/console
echo "$qw $er"
@@ -33,14 +33,11 @@
esac
)
-4)
- consider using typeset -i variable for integer variables
-
-5) don't use sed ! It only causes one more Requires.
+4) don't use sed ! It only causes one more Requires.
Use awk ' { gsub(/pattern/,"replaced"); print $0; } ' for that.
Also try to replace grep calls with awk calls.
-6)
+5)
(PL) Tlumaczac komunikaty na PL nalezy uzywac formy bezosobowej np:
uruchamianie uslugi
Modified: rc-scripts/trunk/rc.d/init.d/functions
==============================================================================
--- rc-scripts/trunk/rc.d/init.d/functions (original)
+++ rc-scripts/trunk/rc.d/init.d/functions Thu Mar 19 01:15:25 2009
@@ -156,7 +156,7 @@
fi
kernelver() {
- typeset _x _y _z v old_IFS ver
+ local _x _y _z v old_IFS ver
{
read _x _y v _z
old_IFS=$IFS
@@ -177,7 +177,7 @@
}
kernelverser() {
- typeset _x _y _z v old_IFS ver
+ local _x _y _z v old_IFS ver
{
read _x _y v _z
old_IFS=$IFS
@@ -193,7 +193,7 @@
}
kernelvermser() {
- typeset _x _y _z v old_IFS ver
+ local _x _y _z v old_IFS ver
{
read _x _y v _z
old_IFS=$IFS
@@ -222,7 +222,7 @@
echo -ne "\033[0K"
;;
setaf)
- typeset ISBOLD
+ local ISBOLD
if [ -n "$3" ]; then
ISBOLD="$3"
else
@@ -254,7 +254,7 @@
# printf equivalent
# FIXME: buggy when single or double quotes in message!
printf() {
- typeset text m
+ local text m
text="$1"
shift
if [ $# -gt 0 ]; then
@@ -271,7 +271,7 @@
# National language support function
nls() {
- typeset msg_echo nls_domain text message
+ local msg_echo nls_domain text message
msg_echo='\n'
nls_domain="$NLS_DOMAIN"
while [ "$1" != "${1##-}" ]; do
@@ -305,9 +305,7 @@
}
rc_splash() {
- typeset action
-
- action="$1"
+ local action="$1"
if ! is_no "$BOOT_SPLASH" && ! is_yes "$VSERVER"; then
[ -x /bin/splash ] && /bin/splash "$action"
@@ -346,8 +344,7 @@
# Some functions to handle PLD Linux-style messages
show() {
- typeset text
- typeset -i len
+ local text len
if is_no "$FASTRC" && is_yes "$GETTEXT"; then
text=$(nls -n "$@")
@@ -375,8 +372,12 @@
# tput setaf). If second argument is not given, default (2, green) will be
# used).
progress() {
- typeset COLOR
- if [ -n "$2" ]; then COLOR="$2"; else COLOR="$CDONE"; fi
+ local COLOR
+ if [ -n "$2" ]; then
+ COLOR="$2"
+ else
+ COLOR="$CDONE"
+ fi
deltext
echo -n "$(termput setaf $CBRACKETS)[$(termput setaf $COLOR) $(nls --nls-domain rc-scripts "$1") $(termput setaf $CBRACKETS)]$(termput op)"
}
@@ -446,9 +447,8 @@
# Usage run_cmd Message command_to_run
run_cmd() {
- typeset exit_code errors message force_err
- typeset -i force_err=0
- typeset -i exit_code=0
+ local exit_code errors message force_err
+ local force_err=0 exit_code=0
case "$1" in
-a)
force_err=1
@@ -504,8 +504,8 @@
# A function to start a program (now it's useful on read-only filesystem too)
daemon() {
- typeset errors="" prog="" end="" waitname="" waittime=""
- typeset -i exit_code=0
+ local errors="" prog="" end="" waitname="" waittime=""
+ local exit_code=0
local nice=$SERVICE_RUN_NICE_LEVEL
local fork user closefds pidfile makepid chdir=/
@@ -649,7 +649,7 @@
# A function to stop a program.
killproc() {
- typeset notset killlevel base pid pidfile result
+ local notset killlevel base pid pidfile result
# Test syntax.
if [ $# = 0 ]; then
msg_usage " killproc [--pidfile PIDFILE] {program} [-SIGNAME]"
@@ -676,7 +676,7 @@
busy
- typeset -i notset=0
+ local notset=0
# check for second arg to be kill level
if [ -n "$2" ]; then
killlevel=$2
@@ -784,7 +784,7 @@
# A function to find the pid of a program.
pidofproc() {
- typeset pid pidfile base=${1##*/}
+ local pid pidfile base=${1##*/}
pidfile="$base.pid"
[ -n "$2" ] && pidfile="$2"
@@ -801,8 +801,7 @@
pidfile="/var/run/${pidfile}";
fi
if [ -f "${pidfile}" ]; then
- typeset p pid
- pid=
+ local p pid=""
for p in $(< "${pidfile}"); do
[ -z "$(echo "$p" | awk '{gsub(/[0-9]/,"");print;}')" ] && pid="$pid $p"
done
@@ -815,7 +814,7 @@
}
status() {
- typeset pid subsys daemon cpuset_msg pidfile
+ local pid subsys daemon cpuset_msg pidfile
if [ "$1" = "--pidfile" ]; then
pidfile=$2
[[ "$pidfile" != /* ]] && pidfile="/var/run/$pidfile"
@@ -874,7 +873,7 @@
# Confirm whether we really want to run this service
confirm() {
- typeset answer
+ local answer
nls -n "Start service %s (Y)es/(N)o/(C)ontinue? [Y] " "$1"
read answer
case $answer in
@@ -908,7 +907,7 @@
}
_modprobe() {
- typeset parsed single die args foo result
+ local parsed single die args foo result
parsed=no
while is_no "$parsed"; do
case "$1" in
@@ -975,8 +974,6 @@
# Check if any flavor of portmapper is running
check_portmapper() {
- typeset RPCINFO
-
if [ -x /usr/sbin/rpcinfo ]; then
if /usr/sbin/rpcinfo -p localhost >/dev/null 2>/dev/null; then
return 0
@@ -993,8 +990,8 @@
# is_fsmounted fstype mntpoint
# Check if filesystem fstype is mounted on mntpoint
is_fsmounted() {
- typeset fstype=$1
- typeset mntpoint=$2
+ local fstype=$1
+ local mntpoint=$2
[ -n "$fstype" -a -n "$mntpoint" ] || return 1
Modified: rc-scripts/trunk/rc.d/rc
==============================================================================
--- rc-scripts/trunk/rc.d/rc (original)
+++ rc-scripts/trunk/rc.d/rc Thu Mar 19 01:15:25 2009
@@ -149,8 +149,8 @@
text_size="$(nls '%sResource Manager: %sEntering runlevel number' "" "")"
resp_size="$(nls 'DONE')"
{
- typeset _len=${#text_size}
- typeset -i _last_col=$(($INIT_COL+${#resp_size}-${#runlevel}))
+ local _len=${#text_size}
+ local _last_col=$(($INIT_COL+${#resp_size}-${#runlevel}))
while [ $((_len++)) -lt $_last_col ]; do
text="$text."
done
@@ -256,8 +256,8 @@
text="$(nls '%sResource Manager: %sRunlevel has been reached' "$af2" "$af7")"
text_size="$(nls '%sResource Manager: %sRunlevel has been reached' "" "")"
{
- typeset -i _len=${#text_size}
- typeset -i _last_col=$(($INIT_COL+${#resp_size}-${#runlevel}))
+ local _len=${#text_size}
+ local _last_col=$(($INIT_COL+${#resp_size}-${#runlevel}))
while [ $((_len++)) -lt $_last_col ]; do
text="$text."
done
Modified: rc-scripts/trunk/rc.d/rc.sysinit
==============================================================================
--- rc-scripts/trunk/rc.d/rc.sysinit (original)
+++ rc-scripts/trunk/rc.d/rc.sysinit Thu Mar 19 01:15:25 2009
@@ -40,7 +40,7 @@
. /etc/rc.d/init.d/functions
disable_selinux() {
- typeset _d selinuxfs _t _r
+ local _d selinuxfs _t _r
while read _d selinuxfs _t _r; do
[ "$_t" = "selinuxfs" ] && break
@@ -52,7 +52,7 @@
}
relabel_selinux() {
- typeset _d selinuxfs _t _r
+ local _d selinuxfs _t _r
while read _d selinuxfs _t _r; do
[ "$_t" = "selinuxfs" ] && break
Modified: rc-scripts/trunk/sysconfig/network-scripts/functions.network
==============================================================================
--- rc-scripts/trunk/sysconfig/network-scripts/functions.network (original)
+++ rc-scripts/trunk/sysconfig/network-scripts/functions.network Thu Mar 19 01:15:25 2009
@@ -7,7 +7,7 @@
source_config ()
{
- typeset foundconfig=0
+ local foundconfig=0
DEVNAME=${CONFIG##*/}
DEVNAME=${DEVNAME##ifcfg-}
@@ -60,7 +60,7 @@
set_hostname()
{
- typeset hostname domain
+ local hostname domain
hostname=$(echo $1 | awk ' { gsub(/\..*$/,NIL); print $0; } ')
domain=$(echo $1 | awk ' { sub(/^[^\.]*\./,NIL); print $0; } ')
@@ -107,7 +107,7 @@
# Setup Network Address Translation (NAT)
setup_nat()
{
- typeset src via dst
+ local src via dst
if [ -r /etc/sysconfig/static-nat ]; then
if [ "$1" = "on" ]; then
@@ -127,7 +127,7 @@
# Setup static ARP
static_arp()
{
- typeset rc arpdev host hwaddr flags neflags
+ local rc arpdev host hwaddr flags neflags
if is_yes "$STATIC_ARP" && [ -r /etc/ethers ]; then
if [ -x /sbin/arp ]; then
@@ -310,7 +310,7 @@
#
setup_routes()
{
- typeset args
+ local args
if [ -f /etc/sysconfig/static-routes ]; then
if [ "$1" = "on" -o "$1" = "yes" ] ; then
@@ -354,7 +354,7 @@
# calculate network prefix from given network mask
calcprefix()
{
- typeset old_IFS netmask prefix endp
+ local old_IFS netmask prefix endp
old_IFS=$IFS
IFS='.'
@@ -384,13 +384,13 @@
# (c) 1999 Grzegorz Stanislawski <stangrze at open.net.pl>
calcnetmask()
{
- typeset prefix a MASK
+ local prefix a MASK
MASK=""
if [ "${1##[0-9]*}" ]; then
prefix=32
else
- typeset -i prefix=$1
+ prefix=$1
fi
for i in 1 2 3 4; do
case $prefix in
@@ -439,7 +439,7 @@
# Olgierd Pieczul <wojrus at pld-linux.org>
setup_ip_rules ()
{
- typeset args prio from src
+ local args prio from src
if [ -f /etc/sysconfig/static-routes ] ; then
if is_yes "$1"; then
More information about the pld-cvs-commit
mailing list