LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 02-01-2012, 01:03 PM   #1
DirtyHowi
Member
 
Registered: Jan 2012
Posts: 34

Rep: Reputation: Disabled
Revamping Linux Echo


On our UNIX system we use something like echo "All\nYes\nNo\n" in a popup box in COBOL which works fine, in linux however we need to do a echo -e "All\nYes\nNo\n"

rather than rewrite unknown lines of code to make this work, is there any way to make -e the default behavior of echo on linux?
 
Old 02-01-2012, 01:10 PM   #2
suicidaleggroll
LQ Guru
 
Registered: Nov 2010
Location: Colorado
Distribution: OpenSUSE, CentOS
Posts: 5,573

Rep: Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142
You could add an alias in your startup script

Code:
 alias bash='bash -e'
 
Old 02-01-2012, 02:44 PM   #3
DirtyHowi
Member
 
Registered: Jan 2012
Posts: 34

Original Poster
Rep: Reputation: Disabled
works great on the command line...alias shows up under all profiles, but it still fails in cobol, am researching. thanks for the tip
 
Old 02-02-2012, 06:08 AM   #4
David the H.
Bash Guru
 
Registered: Jun 2004
Location: Osaka, Japan
Distribution: Arch + Xfce
Posts: 6,852

Rep: Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037
This is not a UNIX/LINUX thing. Since the POSIX standard doesn't specify which behavior should be the default, it's left up to the individual shell to decide how to implement it.

bash, the default shell on most linux systems, does not interpret baskslash forms by default, so you have to use the -e option. I believe ksh, on the other hand, does. I don't know about other shells.

You can use bash's xpg_echo shell option to enable automatic interpretation.

Code:
shopt -s xpg_echo

Edit: To tell the truth, I'm not sure what you mean exactly by using echo "in cobol". Could you perhaps be using the external /bin/echo in cobol programs?

If so, then the same issue as the above applies, and the gnu version of echo is also designed without automatic interpretation. I don't know if there's any way to tell it to do otherwise; the documentation doesn't mention anything.

If you really want to solve your problem at the root, try switching everything to use printf instead. It's more consistent across implementations.

Last edited by David the H.; 02-02-2012 at 08:08 AM. Reason: as stated
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
grep | xargs -I echo $(foo; bar; echo $(fee; fi; fo; fum)) == questionable output.. GrapefruiTgirl Programming 11 12-07-2010 07:02 PM
Revamping the server-client configuration in our lab vivek.sesha Linux - Networking 1 06-18-2007 10:00 AM
ls | echo, I got blank, why can't echo take the 2nd seat in a pipeline? elinuxqs Linux - Newbie 6 11-24-2006 08:25 AM
LXer: Revamping the Web Browser LXer Syndicated Linux News 0 06-12-2006 04:33 PM
Kphone echo (echo echo) scabies Linux - Software 0 10-18-2004 02:59 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 08:58 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration