I am having an issue releated to shell-environment on a server.
Let me explain with the example of below script:
#!/bin/ksh
echo " enter:\c"
read a
echo $a
As I am using ksh the expected output from this script should be 'enter:' (expecting the input for read in same line)
However, the output that I am getting is enter:\c ( which is expecting the input for read in next line).
Please suggest how to solve this issue?
I cannot use another shell here as the application that I am using has multiple scripts in ksh only.
[root@xxx ~]# su - xxxx
$ ksh
$
$
$ echo ${.sh.version}
Version M 93s+ 2008-01-31
$
$ type echo
echo is a shell builtin
$ echo " enter:\c"
enter:\c
$ which ksh
/bin/ksh
$
Might be that it's rather got something to do with the way your terminal interprets escape sequences than with the shell itself, as it's even working with ksh88 on HP-UX and pdksh on Linux.
Just to add that the behavior of echo when the first arg does not begin with a -, and none of the arguments contain a \, is defined as system dependent in the ksh93 man pages.
echo [ arg . . . ] When the first arg does not begin with a -,
and none of the arguments contain a \, then echo prints each of
its arguments separated by a space and terminated by a new-line.
Otherwise, the behavior of echo is system dependent and print or
printf described below should be used. See echo(1) for usage and
description.
As already stated, you could (and in my opinion you should) use printf instead of echo.