]> git.ipfire.org Git - thirdparty/util-linux.git/commit
Rename: fix empty 'from' with / in filename.
authorPhilip Hazelden <philip.hazelden@gmail.com>
Sun, 3 Jul 2022 21:46:16 +0000 (22:46 +0100)
committerPhilip Hazelden <philip.hazelden@gmail.com>
Sun, 3 Jul 2022 21:59:28 +0000 (22:59 +0100)
commit8a6c0e598937aa26ab061214a08374a708249306
treedb88094707474927367797095b65ae26befa3e9c
parent8cdb31d149fb347d71ed266437eadf8df1ab4eb5
Rename: fix empty 'from' with / in filename.

Previously, if we did e.g.

    rename '' _ ./foo.txt

it would try to rename to ._/foo.txt, because `string_replace` was
passed `s="/foo.txt"` and `from` would match at the front. Now we pass
`s="foo.txt"`.

This doesn't affect the case when `to` contains a slash. In that
situation we'll still place `to` at the very beginning of the path, e.g.

    rename '' _/ ./foo.txt # rename to _/./foo.txt
    rename '' /_ ./foo.txt # rename to /_./foo.txt
misc-utils/rename.c
tests/expected/rename/subdir
tests/ts/rename/subdir