Re: [Bashburn-info] Copy Data CD to CD Issues
Brought to you by:
bashburn
From: Fabian S. <fa...@sc...> - 2008-10-01 13:54:14
|
Steven W. Orr wrote: > * The copy command is using globbing. Globbing is evil. We need to only > copy files that are explicitly specified. If you copy by saying something > like... > The shell is globbing. cp will never do it. It's the shell. The globbing can be avoided easily by using single quotation marks. > cp dir/* somewhere/ > > Then there's no way to detect that the cp didn't pick something up. We > have to either verify that the disk is mounted and/or we have to always > specify explict files. DEATH TO GLOBBING. > > Of course you can detect if cd "didn't pick something up". cd will pick every file supplied as a command line argument before the last (target). if someting goes wrong the return value/exit code of cd will not be 0. the shell does the globbing, thus instead of 'dir/*', 'dir/a' 'dir/b' is supplied to cp as command line argument if 'dir/a' and 'dir/b' exist. If you do something like 'cp dir/* somewhere/' you will get an error if 'dir/' is empty. This is because if 'dir/' is empty the shell will not do globbing for the asterisk. So cp will complain that it can't find the file 'dir/*'. I think before doing major changes here...maybe somebody just forgot to check $? after the cp invocation. Just my 2 cents, Fabian |