Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- echo .
- echo This bash script demonstrates a spurious message when cp -p is used to copy files to a MSDOS FAT32 formatted drive.
- echo This script is run on the Terminal application of a MacBook Pro [OS X 10.11.6] [ darwin ].
- echo We start with two identical files, test1,txt and test2.txt to be copied to a flash drive.
- echo test1.txt has NOT been recently edited and the command produces NO error message.
- cp -p -v test1.txt /VOLUMES/KMOVER/testout1.txt
- echo .
- echo test2.txt is a recently edited file so the below produces a spurious error message even though the copy works.
- cp -p -v test2.txt /VOLUMES/KMOVER/testout2.txt
- echo The error message above is expected to appear as follows:
- echo "cp: fchflags: /Volumes/KMOVER/testout2.txt: Invalid argument"
- echo .
- echo The ls -la command results below shows that both copies worked, all .txt files have exactly the same size, and their modification date/times are preserved.
- ls -la test*.txt
- ls -la /VOLUMES/KMOVER/test*.txt
- echo .
- echo So far, I have noticed three conditions that cause this spurious message for a cp.
- echo Without any one of these, the spurious message is not present.
- echo 1. The source file has a recent date [less than a few hours old].
- echo 2. The -p parameter is specified to preseve the modification date.
- echo 3. The copy is to an MSDOS FAT32 flash drive.
- echo .
- echo I suspect this is a bug in cp or fchflags.
- echo Can anyone please confirm this and advise on what to do about it.
Add Comment
Please, Sign In to add comment