bug#14299: Incorrect output of `printf "\\n"`

2013-04-29 Thread Pavel Elkind
Dear developers,

I found the following potential bug in printf (version 8.17).

Actual result: 
`printf "\\n"` prints a newline caracter.

Expected result:
`printf "\\n"` prints a sequence of two individual characters, '\' and 'n', 
like '\n',  but  not a newline character.

Please address the above issue,

Many thanks,
Pavel




bug#13127: [PATCH] cut: use only one data strucutre

2013-04-29 Thread Philipp Thomas
Am 28.04.2013 04:40, schrieb Pádraig Brady:

>  2. When --output-delimiter is specified, it will allocate 31 buckets.
> Even if a few ranges are specified.

Shouldn't this be "Even if only a few ranges are specified"?

Philipp






bug#14299: Incorrect output of `printf "\\n"`

2013-04-29 Thread Eric Blake
tag 14299 notabug
thanks

On 04/28/2013 12:44 PM, Pavel Elkind wrote:
> Dear developers,
> 
> I found the following potential bug in printf (version 8.17).
> 
> Actual result: 
> `printf "\\n"` prints a newline caracter.

Of course.  That's what POSIX requires it to print.

$ set -x
$ printf ".\\n."
+ printf '.\n.'
.
.
$ set -

> 
> Expected result:
> `printf "\\n"` prints a sequence of two individual characters, '\' and 'n', 
> like '\n',  but  not a newline character.

If you want printf to print a literal backslash, you have to properly
escape it.  There are two levels of escaping to consider; shell escaping
(before printf ever sees its argv), and printf escaping.  You missed a
level, because you forgot that within "", the shell converts \\ into a
literal \ as part of the argv, and as my 'set -x' trace showed above,
you were passing only one backslash, not two, to printf.  Within printf,
when it sees the single backslash-n sequence, it converts that escape
sequence to newline.

You probably meant to do any one of these equivalent actions:

printf '.\\n.'
printf .n.
printf ".n."

all of which result in the argv handed to printf still containing two
backslashes.

As such, I'm closing this as not a bug, although you may continue to
reply here if you have further comments.

-- 
Eric Blake   eblake redhat com+1-919-301-3266
Libvirt virtualization library http://libvirt.org



signature.asc
Description: OpenPGP digital signature


bug#14299: Incorrect output of `printf "\\n"`

2013-04-29 Thread Davide Brini
On Sun, 28 Apr 2013 18:44:23 +, Pavel Elkind  wrote:

> Dear developers,
> 
> I found the following potential bug in printf (version 8.17).
> 
> Actual result: 
> `printf "\\n"` prints a newline caracter.
> 
> Expected result:
> `printf "\\n"` prints a sequence of two individual characters, '\' and
> 'n', like '\n',  but  not a newline character.
> 
> Please address the above issue,

printf '\\n'

is what you want. Printf has nothing to do with this, it's the shell that
interpolates \\ when it's in double quotes.


-- 
D.





bug#14318: sort: unexpected results

2013-04-29 Thread Kenneth Dickman
Why does putting "depot" in the input file, corrupt the sort function? How can 
I get sort to operate properly?

$ cat good
bin/... //b/bin/...
logs/... //logs/...
... //b/...
$ sort good
... //b/...
bin/... //b/bin/...
logs/... //logs/...
$ cat bad
bin/... //depot/b/bin/...
logs/... //depot/logs/...
... //depot/b/...
$ sort bad
bin/... //depot/b/bin/...
... //depot/b/...
logs/... //depot/logs/...
$

This occurs on RedHat:

$ uname -a
Linux hidden-name 2.6.32-71.15.1.el6.x86_64 #1 SMP Sun Jan 23 10:39:44 EST 2011 
x86_64 x86_64 x86_64 GNU/Linux
$ which sort
/bin/sort
$ file /bin/sort
/bin/sort: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically 
linked (uses shared libs), for GNU/Linux 2.6.18, stripped
$

And on Linux Mint (which is on top of Ubuntu):

$ uname -a
Linux hidden_name 3.2.0-23-generic #36-Ubuntu SMP Tue Apr 10 20:39:51 UTC 2012 
x86_64 x86_64 x86_64 GNU/Linux
$ which sort
/usr/bin/sort
$

Thanks for your help!
Ken