make 'cwd' work without 'expand' option

When using `expand` with `cwd` it always treats `dest` as a directory. This patch fixed that. However I am not sure if it's the correct way because it may break when `expand` is given (not tested).