On Sun, Jan 27, 2008 at 02:11:26AM +0000, Matthew Szudzik wrote:
> I recently noticed that the examples in the softraid man page
> 
>  http://www.openbsd.org/cgi-bin/man.cgi?query=softraid
> 
> contain many lines such as
> 
>  echo "d a\na\n\n\n\nRAID\nw\nq\n" | disklabel -E wd1
> 
> Of course, not every version of echo interprets "\n" as a newline.  In
> fact, /bin/echo treats "\n" as a literal backslash followed by a literal
> n.  The version of echo that is built into csh also interprets it as a
> literal backslash followed by a literal n.  But the softraid man page
> certainly intends it to be interpreted as a newline.
> 
> So, is the man page in error?  Or are the examples in man pages only
> intended for use in the default shell?  (Note that ksh is the default
> shell, and ksh has a built-in echo command that interprets "\n" as a
> newline.)

well, the man page is not exactly in error - it just presupposes the use
of the default shell. unfortunately /bin/echo does not support character
sequences such as "\n", even though they are noted as mandated by XSI.
bummer.

marco: can we use printf(1) instead? i think we'd need an extra "\n" (no
idea why):

        echo "d a\na\n\n\n\nRAID\nw\nq\n"
would become:
        printf "d a\na\n\n\n\nRAID\nw\nq\n\n"

we'd maybe need to replace all echo commands with printf. it would at
least be more portable.

jmc

Reply via email to