Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: why doesn't 'source *' work?



Timothy J Luoma <tjlists@xxxxxxxxxxx> writes:

> Is there a reason why 'source *' doesn't work?
> 
> Is there a setopt I need to configure?

In what way doesn't it work?

According to the manual:

 . file [ arg ... ]
   Read commands from file and execute them in the current shell
   environment.  If file does not contain a slash, or if PATH_DIRS is
   set, the shell looks in the components of $path to find the
   directory containing file.  Files in the current directory are not
   read unless `.' appears somewhere in $path.

   If any arguments arg are given, they become the positional
   parameters; the old positional parameters are restored when the
   file is done executing.  The exit status is the exit status of the
   last command executed.

source is approximately the same as ".".

I'm guessing you missed the bit about the positional parameters.

If you want to source all the files (giving them no parameters),
you'll need to use a loop:

for i in *
do
   source $i
done

You could wrap this in an autoloaded function, if you wanted.  But not
a shell script, obviously.  (Well, probably not.)



Messages sorted by: Reverse Date, Date, Thread, Author