Skip to content

cp: when multiple flags are specified only the final one should take effect #9954

@ChrisDryden

Description

@ChrisDryden

Problem

GNU cp states: "If more than one of -H, -L, and -P is specified, only the final one takes effect."

Currently in uutils, -H and -P/-L are tracked independently, so combining them doesn't respect flag ordering. For example, -HP should have -P win (don't follow symlinks), but both flags end up being set.

Example:

mkdir test && cd test
echo "content" > file.txt
ln -s file.txt symlink

GNU:

  cp -HP symlink dest_hp
  file dest_hp # dest_hp: symbolic link to file.txt


  cp -PH symlink dest_ph
  file dest_ph # dest_ph: ASCII text

uutils

  uutils-cp -HP symlink dest_hp_uu
  file dest_hp_uu # dest_hp_uu: ASCII text  (WRONG - should be symlink)

This was partially inspired by the Busybox HLP test where this is one of the two issues that's causing it not to pass, the other part of it is way more complicated but this one should just be able to be fixed by updating the overrides_with_all notation in the clap builder and would be a good first issue for a new contributor that's at the uutils rustnyc workshop

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions