bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Ansi-C backslash expansion: $'n' in a double-quoted string adds single-q


From: Enrique Perez-Terron
Subject: Ansi-C backslash expansion: $'n' in a double-quoted string adds single-quote newline single-quote
Date: Fri, 02 Sep 2005 23:47:29 +0200
User-agent: Opera M2/8.02 (Linux, build 1272)

Hello,

The command

  echo "${PATH//:/$'\n'}"

yields

  /usr/bin'
  '/bin'
  '/usr/X11R6/bin

while

  newline=$'\n'
  echo "${PATH//:/$newline}"

yields

  /usr/bin
  /bin
  /usr/X11R6/bin

Is this by intention?

  $ bash --version
  GNU bash, version 3.00.16(1)-release (i386-redhat-linux-gnu)
  Copyright (C) 2004 Free Software Foundation, Inc.

By the way, I wish a search for \$\' and \$\" in the man page would turn up 
something for each.
Presently, I only get something for \$\". The hit is the description of the 
"extquote" shopt option.

The form $"string" is described as:

  A  double-quoted string preceded by a dollar sign ($) will cause...

so you don't find it searching for $".

No single-quotes are searchable, because they are represented in the man page 
with the utf byte sequence 342 200 231 octal. I know of no way to generate that 
character with my keyboard. Even cut-n-paste does not work using gnome-terminal 
and less.

The situation is slightly better under info, but there the single quotation 
mark closes every quotation made by the info text itself.  Fortunatly the 
description of the $'string' form is among the first things that turn up when 
searching for $' although there is a risk people will give up thinking there 
will be a zillion places with the three character `$' mentioning the $ 
character.

Regards,
Enrique




reply via email to

[Prev in Thread] Current Thread [Next in Thread]