I'm writing a bash script that dumps a specified directory into a destination directory (or the current directory if no destination is specified.) The script works fine if the destination directory is specified, but when I try to use the current directory (via $PWD) I get the following error.
mv: `test' and `/home/user/programming/bash/test' are the same file
The current working directory is just /home/user/programming/bash. For some reason the directory I want to dump is being appended onto the current directory path. The function I've created for the dumping is the following.
dump_dir()
{
echo "Dumping \"$1\" into \"$2\"..."
mv -i $1 $2
}
How would I do this using mv? Is there a better command to do this?
EDIT:
Running the command dump_dir test $PWD gives the output
Dumping "test" into "/home/user/programming/bash"...
Then followed by the error which I stated above. For some reason the mv command takes $PWD and appends "test" to the end of it.
EDIT:
To replicate the error open a terminal and type
mv some_directory $PWD
Obviously replace some_directory with an actual directory ;)
EDIT: Again...sorry :)
I'm call the function as follows when the user supplies only the directory to dump.
dump_dir $1 $PWD