bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Suggestion for .bashrc


From: Matthew Persico
Subject: Re: Suggestion for .bashrc
Date: Mon, 10 Jan 2022 20:08:40 -0500

On Tue, Jan 4, 2022 at 3:38 PM Greg Wooledge <greg@wooledge.org> wrote:

> On Tue, Jan 04, 2022 at 03:34:05PM -0500, Matthew Persico wrote:
> > On Fri, Dec 31, 2021 at 10:33 AM Greg Wooledge <greg@wooledge.org>
> wrote:
> > > You can edit the file yourself and make it work however you like.  You
> > > have the right idea, but I'd write it like this:
> > >
> > > if [[ -d ~/.bash_aliases.d ]]; then
> > >     for f in ~/.bash_aliases.d/*; do
> > >
> >
> > Doesn't that shell expansion in the 'for' loop need to be protected
> somehow
> > so that if there are no files in the directory, the loop does not try to
> > process literally the file '*' in that directory?
> >
> >         [[ -f $f ]] && source "$f"
> > >     done
> > > fi
>
> That's precisely what the [[ -f $f ]] check is for.  You could use -e
> instead of -f if you prefer, just in case you ever want it to be able
> to source named pipes or something.
>
> I was reading this in gmail and that example was below the triple dots, so
I didn't see it. Face-palm.

-- 
Matthew O. Persico


reply via email to

[Prev in Thread] Current Thread [Next in Thread]