[vox-tech] Ubuntu 10.04 LTS upgrade woes

Chanoch (Ken) Bloom kbloom at gmail.com
Tue Jan 18 18:40:06 PST 2011


On Tue, 2011-01-18 at 18:07 -0800, Bill Broadley wrote:
> On 01/18/2011 03:43 PM, Brian Lavender wrote:
> > tar cf dotfiles.tar .[!.]* || exit 2
> 
> I agreed with most of Brian's post, but the above seems unnecessarily complex 
> and useless.  My best guess is that someone is paranoid, doesn't understand 
> that ".." is a special case, or maybe it's portable to some broken version of 
> tar like solaris's.
> 
> To demonstrate:
> bill at kona:~/tmp/t2$ tar cvzf ../t1.tar .[!.]*
> .bar
> .blarg
> .foo
> .zoop/
> bill at kona:~/tmp/t2$ tar cvzf ../t2.tar .
> ./
> ./.foo
> ./.bar
> ./.blarg
> ./.zoop/
> bill at kona:~/tmp/t2$
> 
> No protecting against ".." necessary.  Nor would ~/..foo be accidentally
> excluded (unlikely but legal).  Nor am I sure what || exit 2 is supposed to 
> do.  Well I know about return values... but why?
> 
> Does anyone know of a Linux tar that doesn't behave like the above?

I think you're misreading his intent.

He wants *only* the dotfiles (and none of the regular files), so what he
wants is 

    tar zcf dotfiles.tar .*

However, when you ask for .*, the expansion includes . so your entire
home directory is tarred up in the tarball. He should change it to 

    tar zcf dotfiles.tar .?*

which will require at least an additional character. But when you do
this, .. is included in the glob expansion, and so .. and all its
children get included in the tarball. (Yes, I tested on GNU tar)

That's why he changed it to the following, which requires there be a
non-dot character after the dot

    tar zcfv dotfiles.tar .[!.]*



More information about the vox-tech mailing list