Bug 166955

Summary: echo ignores \c to supress newlines
Product: [Fedora] Fedora Reporter: Frank Farance <frank>
Component: bashAssignee: Tim Waugh <twaugh>
Status: CLOSED NOTABUG QA Contact:
Severity: medium Docs Contact:
Priority: medium    
Version: 4   
Target Milestone: ---   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2006-01-19 10:05:41 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

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.