Try to do all file operations even when one or some of them fail, and
use exit value to inform what happen.
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Earlier the rename(1) considered path as possible string to be renamed,
could lead to an issue with none existing destination. See below for
demonstration of this issue. After this change all directory elements
are ignored when the match finding happens.
$ cd $(mktemp -d)
$ mkdir aa ab
$ touch a{a,b}/aa
$ rename -v a x */aa
rename: aa/aa: rename to xa/aa failed: No such file or directory
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
The rename has new verbose option which will print which files
where renamed. Maintenance fixes includes long options, coding
style and freeing memory after usage.
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
The number of files successfully renamed is calculated and stored in variable
ct, > but actually the variable is not used afterwards.
Signed-off-by: Li Zefan <lizf@cn.fujitsu.com>