LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Debian (https://www.linuxquestions.org/questions/debian-26/)
-   -   change echo default setting to -e in Etch (https://www.linuxquestions.org/questions/debian-26/change-echo-default-setting-to-e-in-etch-537007/)

fangorn 03-13-2007 02:19 AM

[Solved] change echo default setting to -e in Etch
 
Hi,

I have a problem with the default setting for "echo" command in Debian.

I have hundred of old scripts written for AIX and /bin/ksh. These I want to run in Debian Etch and /bin/ksh.

The Problem is, AIX "echo" command does not even know of the -e option. Therefore there is in none of the scripts a "echo -e " present when \ Escape sequences are used to echo non-printable characters.

ksh does not have an internal echo command, so it uses the system wide one. As Debian "echo" command defaults to -E (which ignores these Escape sequences and prints them as ASCII), I cannot run these scripts under Debian Etch.

I also cannot and do not want to change all the scripts to be echo -e instead of echo, as they still have to run on AIX (and other linux distributions). I would have to deeply edit any script and add a OS agnostic solution. Not an option.

Is there a switch to set to change that default behaviour?

I stumbled over some more or less dirty hacks to come around this.

- insert a script "echo" somewhere in the PATH before /bin (but what is before /bin in every PATH variable? not really a solution, unless deeply hacking into the system
- move /bin/echo to /bin/echo-bin and replace it with a script /bin/echo *shudder*
- remove ksh from the installation and replace it with a script that lauches a bash shell (which has an internal echo command that you can set the behaviour of) and sets the readline mode to vi. The users would probably never recognize the difference. But I am pretty sure some of the scripts will break
- recompile the package that provides echo command (think this has to be glibc) with more usable default settings *wild_shudder*

I would rather not use one of those "solutions". I think it is obvious why not.

So please show me what I am missing.

Thanks in advance for any tip,
fangorn


Edit: Problem solved [kinda].

pdksh provides an internal echo command with a more "compatible" behaviour. Lets see if some of the scripts crash.

JimBass 03-13-2007 09:42 AM

I'm not much of a shell scripter, but this part of your question has an easy solution -
Quote:

- insert a script "echo" somewhere in the PATH before /bin (but what is before /bin in every PATH variable? not really a solution, unless deeply hacking into the system
If you check /etc/profile, you'll see the default $PATH, and /bin is 3rd on that list. /usr/local/bin and /usr/bin are called before it gets to /bin.

Since you solved it on your own it isn't important, but /usr/local/bin is a great place for any account with a valid shell to hit first.

Peace,
JimBass


All times are GMT -5. The time now is 06:54 PM.