bug-coreutils
[Top][All Lists]
Advanced

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

bug#70639: Bug or Misleading Description of realpath command


From: Collin Funk
Subject: bug#70639: Bug or Misleading Description of realpath command
Date: Sun, 28 Apr 2024 19:18:05 -0700
User-agent: Mozilla Thunderbird

On 4/28/24 4:37 PM, Hazel Cooney wrote:
> To reproduce this bug, create a directory with some files in it. Then, go
> to the directory that contains the one you just made. Type ls new_directory
> | xargs realpath.

Using 'build-aux' for my directory instead of music_copy. We have this
for build-aux:

    ls build-aux
    announce-gen    config.libpath    depcomp ....

>From the 'realpath' info page we have:

   By default, all but the last component of the specified files must
   exist.

Then when we perform the 'ls build-aux | xargs realpath', we don't
change our current working directory. So that is why we get:

    # Notice 'build-aux' is missing after gnulib.
    $ ls build-aux | xargs realpath
    /home/collin/.local/src/gnulib/announce-gen
    /home/collin/.local/src/gnulib/ar-lib
    /home/collin/.local/src/gnulib/bootstrap

There might be a better way to write it, but I would do this:

    $ for file in build-aux/*; do echo $file; done | xargs realpath
    /home/collin/.local/src/gnulib/build-aux/announce-gen
    /home/collin/.local/src/gnulib/build-aux/ar-lib
    /home/collin/.local/src/gnulib/build-aux/bootstrap

Since unlike 'ls' that loop does not remove the directory name:

   $ for file in build-aux/*; do echo $file; done
   build-aux/announce-gen
   build-aux/ar-lib
   build-aux/bootstrap

Does that explination help? Or I misunderstanding your issue?

Collin





reply via email to

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