Bug #24605 mysql_secure_installation uses unsupported option for echo
Submitted: 26 Nov 2006 22:36 Modified: 25 Jan 2007 20:40
Reporter: Daniël van Eeden Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Installing Severity:S3 (Non-critical)
Version:5.0.27 OS:Solaris (Solaris 10)
Assigned to: Kent Boortz CPU Architecture:Any

[26 Nov 2006 22:36] Daniël van Eeden
Description:
/opt/mysql/mysql/bin/mysql_secure_installation (from SVR4 Commuity Server pkg) uses "echo -n" which is not supported

/usr/bin/echo does not support "-n"
/usr/ucb/echo does support "-n"

When the scripts tries to reload the privilege tables after setting the root password this error pop's up.
/opt/mysql/mysql/bin/mysql_secure_installation: !: not found
the tables are not reloaded. Running the script again w/o changing the root password does work. The last step of the script succesfully reloads the privilege tables.

How to repeat:
1. install mysql5
2. run mysql_secure_installation

Suggested fix:
* Use /usr/ucb/echo (not availble on minimun install)
* Don't use "-n" (hard to do)
* Use printf(1) (best way to fix it)
[27 Nov 2006 10:30] Hartmut Holzgraefe
See the "Writing portable Bourne Shell -> Utilities" in
the "GNU Autoconf, Automake and Libtool" book for a possible
solution to this:

http://sourceware.org/autobook/autobook/autobook_220.html#SEC220

    The echo command has at least two flavors: the one takes a `-n' option to suppress the automatic newline at the end of the echoed string; the other uses an embedded `\c' notation as the last character in the echoed string for the same purpose.

    If you need to emit a string without a trailing newline character, you can use the following script fragment to discover which flavor of echo you are using:

     	

    case echo "testing\c"`,`echo -n testing` in
      *c*,-n*) echo_n=   echo_c='(53)
    ' ;;
      *c*,*)   echo_n=-n echo_c= ;;
      *)       echo_n=   echo_c='\c ;;
    esac

    Any echo command after the shell fragment above, which shouldn't move the cursor to a new line, can now be written like so:

     	

    echo $echo_n "prompt:$echo_c"
[1 Jan 2007 4:30] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/17492

ChangeSet@1.2585, 2007-01-01 05:30:31+01:00, kent@mysql.com +2 -0
  mysql_secure_installation.sh:
    Portable handling of "echo" without newline (bug#24605)
  check-cpu:
    In developer script safe to use "printf", not "echo -n"
[2 Jan 2007 10:01] Joerg Bruehe
Ok to push, more comments in separate mail.
[25 Jan 2007 19:05] Joerg Bruehe
The patch was pushed into 5.1.15 on Jan 11 already :-(
It is in 5.0.34 and will be in 4.1.23.
[25 Jan 2007 20:40] Paul DuBois
No changelog entry needed.