Bug 166955 - echo ignores \c to supress newlines
echo ignores \c to supress newlines
Status: CLOSED NOTABUG
Product: Fedora
Classification: Fedora
Component: bash (Show other bugs)
4
All Linux
medium Severity medium
: ---
: ---
Assigned To: Tim Waugh
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2005-08-28 17:29 EDT by Frank Farance
Modified: 2007-11-30 17:11 EST (History)
0 users

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2006-01-19 05:05:41 EST
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description Frank Farance 2005-08-28 17:29:18 EDT
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 17:33:32 EDT
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 05:05:41 EST
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.