kward/log4sh

Hello world example gives an error for 'sed' and 'tr'

Opened this issue · 0 comments

Hi Team :-)

First of all - I like your project very much. Thank you very much for all your work on this project.

Just tried to do the first baby steps on log4sh starting with the famous 'hello world' example according to doc/log4sh.md.

If I use the preconfigured version, I get the following error message in the function
_appender_parsePattern():

++ : _appender_parsePattern 3 -ne 3 8
++ _app_pattern='%-4r [%t] %-5p %c %x - %m%n'
++ _app_priority=INFO
++ _app_msg='Hello, world'
++ _app_date=
++ _app_doEval=1
++ _app_oldIFS=' '
++ IFS=%
++ set -- x '-4r [' 't] ' '-5p ' 'c ' 'x - ' m n
++ IFS=' '
++ '[' 8 -gt 1 ']'
++ IFS=d
++ set -- '%-4r [%t] %-5p %c %x - %m%nx'
++ IFS=' '
++ '[' 1 -gt 1 ']'
++ IFS=X
++ set -- '%-4r [%t] %-5p %c %x - %m%nx'
++ IFS=' '
++ '[' 1 -gt 1 ']'
+++ echo 'Hello, world'
+++ sed 's/\\/\\\\/g;s/&/\\&/g'
++ _app_msg='Hello, world'
+++ echo 'Hello, world'
+++ tr '\n' ''
tr: when not truncating set1, string2 must be non-empty
++ _app_msg=
+++ echo '%-4r [%t] %-5p %c %x - %m%n'
+++ sed -e s/%c/shell/g -e 's/%d{[^}]*}/%d/g' -e s/%d//g -e s/%F/hello_world/g -e s/%L//g -e s/%n//g -e 's/%-*[0-9]*p/INFO/g' -e 's/%-*[0-9]*r/1/g' -e s/%t/main/g -e s/%x//g -e 's/%X{/$\{/g' -e s/%%m/%%%m/g -e s/%%/%/g -e s%m
+++ tr '' '\n'
sed: -e expression #14, char 3: unterminated `s' command
++ _app_pattern=
++ '[' 1 -eq 1 ']'
++ echo ''
++ unset _app_date _app_doEval _app_msg _app_oldIFS _app_pattern _app_tag
++ return 0
....

These are the version informations:
LOG4SH_VERSION='1.5.1pre'
Linux: RHEL5 2.6.18-419.el5
Bash-Version: 3.2.25(1)-release

The script looks as follows:

#
# log4sh example: Hello, world
#
myDir=`dirname $0`

# Find and source log4sh.
if [ -r "$myDir/log4sh" ]; then
  log4shDir=$myDir
elif [ -r "./log4sh" ]; then
  log4shDir=.
else
  echo "fatal: could not find log4sh" >&2
  exit 1
fi

. $log4shDir/log4sh

# Say Hello to the world.
logger_info 'Hello, world'

And finally the properties file...:

#
# log4sh example: Hello, world properties file
#

# Set root logger level to INFO and its only appender to A1.
log4sh.rootLogger=INFO, A1

# A1 is set to be a ConsoleAppender.
log4sh.appender.A1=ConsoleAppender

# A1 uses a PatternLayout.
log4sh.appender.A1.layout=PatternLayout
log4sh.appender.A1.layout.ConversionPattern=%-4r [%t] %-5p %c %x - %m%n

Maybe I just made a misconfiguration (or it's a RHEL issue).
Do you have an idea why this happens?

Kind regards,
Bert99Blib