rename: allow renaming in subdirectories

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>
tests: add function to change directory reliable way

Without arguments bash cd will move to $HOME. Ensure also that when
directory is assumed to be changed the current directory and intented
destination are the same location.

Reference: http://www.spinics.net/lists/util-linux-ng/msg09509.html
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
tests: use ts_cd everywhere to change direcrory

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
tests: add rename(1) checks

Check basic file moves, symlink relinking, and both file moves and
symlinks when operations are have directory in destination path.

Reviewed-by: Ruediger Meier <sweet_f_a@gmx.de>
Reviewed-by: Karel Zak <kzak@redhat.com>
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
rename: continue despite something failed

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>
rename: use function pointer to select file or symlink operation

Add separate functions to different functionality, and add a function for
the stuff that is in common for both.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
tests: add rename(1) return value check

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Merge branch 'rename' of git://github.com/kerolasa/lelux-utiliteetit

* 'rename' of git://github.com/kerolasa/lelux-utiliteetit:
  tests: add rename(1) return value check
  rename: use function pointer to select file or symlink operation
  rename: continue despite something failed
  tests: add rename(1) checks
  tests: use ts_cd everywhere to change direcrory
  tests: add function to change directory reliable way
  rename: allow renaming in subdirectories