[GRASS-dev] Re: [GRASS-CVS] hamish: grass6/lib/init init.sh, 1.120, 1.121

Glynn Clements glynn at gclements.plus.com
Tue Nov 6 19:16:35 EST 2007


Hamish wrote:

> > BTW: this works better for me:
> ..
> >  echo '          __________  ___   __________    _______________'
> >  echo '         / ____/ __ \/   | / ___/ ___/   / ____/  _/ ___/'
> > -echo '        / / __/ /_/ / /| | \__ \\__ \   / / __ / / \__ \ '
> > +echo '        / / __/ /_/ / /| | \__ \\\\_  \\   / / __ / / \\__ \\ '
> >  echo '       / /_/ / _, _/ ___ |___/ /__/ /  / /_/ // / ___/ / '
> >  echo '       \____/_/ |_/_/  |_/____/____/   \____/___//____/  '
> >  echo
> 
> 
> It was my understanding that using 'single quotes' meant that I didn't have to
> worry about it being escaped by the shell? The above is shown literally on
> Debian/etch.

It isn't the shell; it's "echo" that's the problem.

Whether or not the "echo" command interprets escape sequences by
default varies between implementations.

In particular, the GNU version (both the bash built-in and the
standalone echo program from coreutils) does not conform to the Single
Unix Specification.

The SUS interface doesn't support any options, and escape sequences
are always enabled, while the bash version requires that you use -e to
enable them.

POSIX simply states the the behaviour is implementation-defined if any
argument contains a backslash.

	http://www.opengroup.org/onlinepubs/009695399/utilities/echo.html

	http://www.gnu.org/software/coreutils/manual/html_node/echo-invocation.html

> I think that is a Dash nasty? Surely this is messing up someone's regex scripts
> somewhere, and it doesn't smell much like a Bashism.
> 
> $ bash  
> $ echo '\\'
> \\
> $ dash
> $ echo '\\'
> \
> 
> Is the practical solution to bypass the issue by using "double quotes" and
> explicitly double-\\ any intended \\s?

No. If you want to use a backslash, you'll need to forego "echo" in
favour of e.g. a here document:

cat <<EOF
          __________  ___   __________    _______________
         / ____/ __ \/   | / ___/ ___/   / ____/  _/ ___/
        / / __/ /_/ / /| | \__ \\\\_  \\   / / __ / / \\__ \\ 
       / /_/ / _, _/ ___ |___/ /__/ /  / /_/ // / ___/ / 
       \____/_/ |_/_/  |_/____/____/   \____/___//____/  

EOF

-- 
Glynn Clements <glynn at gclements.plus.com>




More information about the grass-dev mailing list