[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Help-bash] How to safely work on files/dirs with .
From: |
Stephane Chazelas |
Subject: |
Re: [Help-bash] How to safely work on files/dirs with . |
Date: |
Mon, 14 Mar 2016 14:38:56 +0000 |
User-agent: |
Mutt/1.5.21 (2010-09-15) |
2016-03-14 10:33:43 -0400, Greg Wooledge:
> On Mon, Mar 14, 2016 at 02:20:15PM +0000, Stephane Chazelas wrote:
> > 2016-03-14 08:40:54 -0400, Greg Wooledge:
> > > For completeness, and to get things back on topic for help-bash,
> > > bash includes a shopt named "dotglob" which makes * match files
> > > beginning with dot.
> >
> > Note that it doesn't prevent the expansion of . and .. in a .*
> > glob (which was the point being discussed here):
> >
> > $ bash -O dotglob -c 'echo .*'
> > . .. .a
>
> So, don't do that.
>
> imadev:~/tmp$ rm *
> imadev:~/tmp$ touch .foo bar
> imadev:~/tmp$ bash -O dotglob -c 'echo *'
> bar .foo
>
> Simple!
The specific point being discussed here was about expanding the
hidden files other than . and ..
To get the same behaviour as zsh/pdksh/fish's
chmod -R +r .*
in bash, you need either
chmod -R +r .[!.]* ..?* # POSIX
or
shopt -s dotglob
chmod -R +r [.]*
or:
GLOBIGNORE=: # anything non-empty
chmod -R .* # but not chmod -R +r dir/.*
--
Stephane
- [Help-bash] How to safely work on files/dirs with ., David Niklas, 2016/03/12
- Re: [Help-bash] How to safely work on files/dirs with ., Bob Proulx, 2016/03/12
- Re: [Help-bash] How to safely work on files/dirs with ., Stephane Chazelas, 2016/03/14
- Re: [Help-bash] How to safely work on files/dirs with ., Greg Wooledge, 2016/03/14
- Re: [Help-bash] How to safely work on files/dirs with ., Stephane Chazelas, 2016/03/14
- Re: [Help-bash] How to safely work on files/dirs with ., Greg Wooledge, 2016/03/14
- Re: [Help-bash] How to safely work on files/dirs with .,
Stephane Chazelas <=
- Re: [Help-bash] How to safely work on files/dirs with ., Bob Proulx, 2016/03/19
- Re: [Help-bash] How to safely work on files/dirs with ., Greg Wooledge, 2016/03/21
- Re: [Help-bash] How to safely work on files/dirs with ., Eric Blake, 2016/03/21