The man page states:
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 descrip-
tion.
While it does not explicitly say it uses an external echo command, the
"echo(1)" man page is for an external command. The reason behavior is
"system dependant" is because the standalone echo command is different
on many platforms.
Based on tracing, I can see ksh work its way through my PATH:
access("/usr/kerberos/sbin/echo", X_OK) = -1 ENOENT (No such file or
directory)
access("/usr/kerberos/bin/echo", X_OK) = -1 ENOENT (No such file or
directory)
access("/usr/local/sbin/echo", X_OK) = -1 ENOENT (No such file or
directory)
access("/usr/local/bin/echo", X_OK) = -1 ENOENT (No such file or
directory)
access("/sbin/echo", X_OK) = -1 ENOENT (No such file or
directory)
# echo $PATH
/usr/kerberos/sbin:/usr/kerberos/bin:/usr/local/sbin:/usr/local/bin:/sbi
n:/bin:/usr/sbin:/usr/bin:/root/bin
When it gets to /bin/echo, it is able to execute...
I see the same behavior Tom does - if I create a link in ANY path
component before /bin, the behavior or ksh is different! It works
handles the escapes.
Initially I thought it might be the echo command acting different, but
its not:
# /bin/echo "blah \c"
blah \c
# /usr/local/bin/echo "blah \c"
blah \c
This means that ksh is specifically behaving differently when it finds
echo as "/bin/echo". I am going to get the source and poke around
because now I am curious.
Thanks,
Kevin
-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of inode0
Sent: Thursday, July 05, 2007 7:40 PM
To: Red Hat Enterprise Linux 5 (Tikanga) discussion mailing-list
Subject: Re: [rhelv5-list] how to handle "echo" ?
On 7/5/07, Tom Sightler <[EMAIL PROTECTED]> wrote:
> Yes, we've also hit this issue on our RHEL5 test environments with
many
> of our ksh scripts, not as many as you have to deal with, but still
more
> than we were interested in changing.
>
> We actually ran an strace on the ksh process and found that it seems
> that it doesn't really call /bin/echo as it should. It appears that
ksh
> looks for the echo command in a portion of the PATH but actually
> ignores /bin for some reason and thus fails to find /bin/echo so it
> falls back to using it's builtin function.
This is strange behavior, although it isn't clear to me that it
"should" call /bin/echo. The man page I'm looking at on RHEL5 doesn't
seem to say that. It says the behavior in this case is "system
dependent."
> We found that simply placing a symbolic link to /bin/echo
> in /usr/local/bin seemed to correct the behavior. I know this seems
> weird, but try it. We think this is a bug but haven't had enough time
> to truly research exactly what's happening and file it. Actually,
we'd
> love to know if this strange workaround actually fixes it for you as
> well.
While that might get it to call an external program wouldn't you still
need to add "-e" to get the desired behavior? And if so, then why not
add the "-e" to the built-in echo anyway?
John
_______________________________________________
rhelv5-list mailing list
[email protected]
https://www.redhat.com/mailman/listinfo/rhelv5-list
_______________________________________________
rhelv5-list mailing list
[email protected]
https://www.redhat.com/mailman/listinfo/rhelv5-list