bug-coreutils
[Top][All Lists]
Advanced

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

bug#28985: expand --tabs transposes expansions in output, does other une


From: Pádraig Brady
Subject: bug#28985: expand --tabs transposes expansions in output, does other unexpected things
Date: Tue, 24 Oct 2017 20:36:25 -0700
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.8.0

tag 28985 notabug
close 28985
stop

On 24/10/17 19:21, Chris King-Parra wrote:
> Package:             coreutils
> Version:             8.28
> 
> Hi there,
> 
> I was reading the info pages for ``expand`` this afternoon and came across the
> 
> ``--tabs`` option. To my understanding, you supply it with a comma separated
> 
> list of numbers. Each number specifies how many spaces to replace the next
> 
> occurrence of a tab with.  The ``/`` character can be used to prefix a number,
> 
> which will then be used for the number of spaces to expand to for every tab in
> 
> and after that occurrence.
> 
> Here's an excerpt of an example from the info page, describing the ``--tabs=``
> 
> option:
> 
>>  As a GNU extension the last tab specified can be prefixed with a ‘/’ to
> 
> indicate a tab size to use for remaining positions. For example, --tabs=2,4,/8
> 
> will set tab stops at position 2 and 4, and every multiple of 8 after that.
> 
> The results weren’t what I expected::
> 
>     address@hidden:~> echo 'one        |two    |three  |' | expand 
> --tabs=2,4,/8 | sed 's/ /#/g' | cat -A
> 
>     one#|two########|three##|$
> 
> For the sake of clarity, here’s the exact command output I expected::
> 
>     address@hidden:~> echo 'one        |two    |three  |' | expand 
> --tabs=2,4,/8 | sed 's/ /#/g' | cat -A
> 
>     one#|two####|three########|$
> 
> Here is some other unexpected, but less specific, behavior::
> 
>     address@hidden:~> echo 'one        |two    |three  |' | expand 
> --tabs=1,2,4 | sed 's/ /#/g' | cat -A
> 
>     one#|two#|three#|$
> 
> Which I expected to result in::
> 
>     one#|two##|three####|$
> 
> Did I find a bug?

I don't think so.
The following should be instructive.
The uppercase letters are the tab stops,
and you can see the spaces aligning to those.

2,4,/8 ≡ 2,4,8,16,24, so

  $ printf '%s\n' 'aBcDefgHijklmnoPqrstuvwXyz' $'one\t|two\t|three\t|' |
    expand --tabs=2,4,8,16,24 | sed 's/ /#/g' | cat -A

  aBcDefgHijklmnoPqrstuvwXyz$
  one#|two########|three##|$

cheers,
Pádraig





reply via email to

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