Project

General

Profile

« Previous | Next » 

Revision 124464b1

Added by The Ranger about 6 years ago

Fixes #12131: Agent script argument parsing failure when using non-default locale

View differences:

bin/rudder
#!/bin/sh
#
# Wrapper to call rudder commands.
#
#
# All commands are taken from $BASEDIR (/opt/rudder/share/commands).
#
# To add a new command, just drop it in this directory with the name <role>-<command>
......
export RUDDER_BIN
role_list() {
ls "${BASEDIR}" | sed 's/\([A-Za-z_]*\)-.*/\1/' | uniq
ls "${BASEDIR}" | sed 's/\([[:alpha:]_]*\)-.*/\1/' | uniq
}
usage() {
......
}
# first parameter is role parameter
role=`echo "$1" | sed 's/[^A-Za-z_-]*//g'`
role=`echo "$1" | sed 's/[^[:alpha:]_-]*//g'`
if [ "${role}" = "help" ] || [ -z "${role}" ]
then
if [ -z "$2" ]
then
usage
else
role=`echo "$2" | sed 's/[^A-Za-z_-]*//g'`
role=`echo "$2" | sed 's/[^[:alpha:]_-]*//g'`
role_usage "${role}"
fi
exit 0
......
fi
# second parameter is command parameter
command=`echo "$1" | sed 's/[^A-Za-z_-]*//g'`
command=`echo "$1" | sed 's/[^[:alpha:]_-]*//g'`
if [ "${command}" = "help" ] || [ "${command}" = "" ]
then
role_usage "${role}"
......
fi
# test if third parameter is --help
option=`echo "$1" | sed 's/[^A-Za-z_-]*//g'`
option=`echo "$1" | sed 's/[^[:alpha:]_-]*//g'`
if [ "${option}" = "--help" ] || [ "${option}" = "-h" ] || [ "${option}" = "help" ]
then
options=`sed -ne "/#[ \t]*@man[ \t]*/s/#[ \t]*@man[ \t]*//p" "${BASEDIR}/${role}-${command}" |
......
# OK GO !
exec "${BASEDIR}/${role}-${command}" "$@"

Also available in: Unified diff