Pádraig Brady <[email protected]> writes:

> * src/ls.c (decode_switches): Flag ',' for quoting when needed.
> * tests/ls/m-option.sh: Add a test case.
> * NEWS: Mention the improvement.
> ---
>  NEWS                 | 3 +++
>  src/ls.c             | 6 ++++++
>  tests/ls/m-option.sh | 8 ++++++++
>  3 files changed, 17 insertions(+)
>
> diff --git a/NEWS b/NEWS
> index b1ec92562..39967eab1 100644
> --- a/NEWS
> +++ b/NEWS
> @@ -60,6 +60,9 @@ GNU coreutils NEWS                                    -*- 
> outline -*-
>    'df', 'du', 'ls', 'od', 'pr', and 'sort' now escape invalid arguments in 
> error
>    messages for options expecting an integer.
>  
> +  'ls -m' now quotes files names containing commas when appropriate,
> +  so users can distinguish separating commas.
> +

Can't you just split by ", " with the output before this patch? E.g.,
looking at the following:

    $ mkdir a; (cd a && touch f1 f1, f1,f2 f1,f2, 'f1, f2' 'f1, f2,')
    $ ls -m a
    f1, f1,, f1,f2, f1,f2,, 'f1, f2', 'f1, f2,'
    
We know the comma is a part of the file name if it is not followed by a
space. And it does have a ", " in it's name it will be quoted anyways
because of the space. Am I missing something?

Also, posting the output with your patch for others reference:

    $ ./src/ls -m a
    f1, 'f1,', 'f1,f2', 'f1,f2,', 'f1, f2', 'f1, f2,'

You'd still need to care for filenames with ", " in their name in this
case.

Collin

Reply via email to