Bug 166955 - echo ignores \c to supress newlines
Summary: echo ignores \c to supress newlines
Keywords:
Status: CLOSED NOTABUG
Alias: None
Product: Fedora
Classification: Fedora
Component: bash
Version: 4
Hardware: All
OS: Linux
medium
medium
Target Milestone: ---
Assignee: Tim Waugh
QA Contact:
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2005-08-28 21:29 UTC by Frank Farance
Modified: 2007-11-30 22:11 UTC (History)
0 users

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2006-01-19 10:05:41 UTC
Type: ---
Embargoed:


Attachments (Terms of Use)

Description Frank Farance 2005-08-28 21:29:18 UTC
From Bugzilla Helper:
User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.7.10) Gecko/20050720 Fedora/1.0.6-1.1.fc4 Firefox/1.0.6

Description of problem:
The command:

echo 'amsdnasmdn\c'

does not suppress the trailing newline.  This is a problem in FC4 in "/bin/echo" and "/bin/ksh".  This was working in FC3.

This has been working for the past 20+ years in Unix systems.  Because of this problem, many many shell scripts are breaking.


Version-Release number of selected component (if applicable):
coreutils-5.2.1-48.1

How reproducible:
Always

Steps to Reproduce:
1.  See description above.
  

Actual Results:  The echo command produces a newline (it should not).

Expected Results:  There should be no newline.

Additional info:

Comment 1 Frank Farance 2005-09-11 21:33:32 UTC
I've done a little more research.  On FC3, the "echo" built-in of "ksh" got it
right.

The main problem is that it is difficult to write a shell script that is
portable across the UNIX/Linux systems.  Even if one uses "-e" in "/bin/echo",
the problem becomes:

        $ echo -e "abcdef\c"

is not portable across UNIX systems.  I am aware that there might be some issues
concerning backward compatibility (e.g., someone's broken sense of "echo" that
is now behaving properly).

Unlike other commands that can take arguments to customize, the "echo" command
shouldn't take any arguments.  One way to allow it to customize itself would be
through environment variables, such as:

        $ ECHO_ARGS="-e --"; export ECHO_ARGS
        $ echo "abcdef\c"

The above use of ECHO_ARGS would mean:

        - "-e" means expand the backslash characters
        - "--" means no more arguments, i.e., "echo" will not interpret any of
its arguments.

Aside from "/bin/echo" supporting this $ECHO_ARGS feature, the shell built-ins
in sh, bash, ksh, and pdksh should support this, too.

It is unrealistic that all the shell scripts have to change (and in a
non-portable, non-standard way) just so they run on Linux systems.  The above
solution approach allows script developers to have a common startup/environment
file, while not having to create Linux-specific scripts.




Comment 2 Tim Waugh 2006-01-19 10:05:41 UTC
Seems like:

shopt -s xpg_echo

is what you're after.


Note You need to log in before you can comment on or make changes to this bug.