X-Git-Url: http://erislabs.net/gitweb/?a=blobdiff_plain;f=tests%2Ftest-echo.sh;h=f4c62d14e733a741a9b165a6d1b3882e3d056078;hb=cbfeef01ad4ed6d3f68c3deb3c05d3b8102c84ff;hp=45eabd7336b61725a73259c111388b6827ba249d;hpb=47b0bff399ab0cca893b38b876d526fb3f088833;p=gnulib.git diff --git a/tests/test-echo.sh b/tests/test-echo.sh index 45eabd733..f4c62d14e 100755 --- a/tests/test-echo.sh +++ b/tests/test-echo.sh @@ -36,8 +36,10 @@ func_fatal_error () # - for bash >= 2.0: define echo to a function that uses the printf built-in. # - for bash < 2.0: define echo to a function that uses cat of a here document. # - for zsh: turn sh-emulation on. +# - for ksh: alias echo to 'print -r'. # - for ksh: alias echo to a function that uses cat of a here document. -# - for Solaris /bin/sh: respawn using /bin/ksh and rely on the ksh workaround. +# - for Solaris /bin/sh and OSF/1 /bin/sh: respawn using /bin/ksh and rely on +# the ksh workaround. # - otherwise: respawn using /bin/sh and rely on the workarounds. # When respawning, we pass --no-reexec as first argument, so as to avoid # turning this script into a fork bomb in unlucky situations. @@ -76,7 +78,7 @@ $* EOF } else - # 'printf' is a shell built-in. Now it's safe to define 'echo'. + # 'printf' is a shell built-in. echo () { printf '%s\n' "$*" @@ -92,6 +94,24 @@ if test -z "$have_echo" \ && (emulate sh) >/dev/null 2>&1; then emulate sh fi +# For ksh: alias echo to 'print -r'. +if test -z "$have_echo" \ + && (type print) >/dev/null 2>&1; then + # A 'print' command exists. + if type print 2>/dev/null | grep / > /dev/null; then + : + else + # 'print' is a shell built-in. + if (print -r '\told' | grep told > /dev/null) 2>/dev/null; then + # 'print' is the ksh shell built-in. + alias echo='print -r' + fi + fi +fi +if test -z "$have_echo" \ + && echo '\t' | grep t > /dev/null; then + have_echo=yes +fi # For ksh: alias echo to a function that uses cat of a here document. # The ksh manual page says: # "Aliasing is performed when scripts are read, not while they are executed.