help-bash
[Top][All Lists]
Advanced

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

Re: [Help-bash] read -r question


From: Eduardo A . Bustamante López
Subject: Re: [Help-bash] read -r question
Date: Thu, 13 Feb 2014 22:09:12 -0800
User-agent: Mutt/1.5.21 (2010-09-15)

On Thu, Feb 13, 2014 at 08:37:13PM -0500, Leonardo Nc wrote:
> Hi, I'll like to know what these lines mean. It is a part of the function
> load_profile() in the arch linux file /usr/lib/network/globals
> 
> while read -r hook; do
>     source "$hook"
>     done < <(find -L "$PROFILE_DIR/hooks" -maxdepth 1 -type f -executable
> -not -name '.*' -not -name '*~' | sort -u)
Ok, first, we'll study the <(...) part, which in the end, evaluates a
command and exposes it as a file to the ''while'' loop. In this case,
the command is ''find'', and its task is to find in the hooks
directory, with a maximum depth of one (not following directories),
all the files which are also executable, and which are not hidden
files (.*) and backup files (*~).

Then, that list of filenames, one per line, is fed to a loop, that
reads them as "hooks", and for each hook, it ''source''s it, which
basically means load the file as bash code in the current shell.

> 
> at the beginning of the function is declared a local variable called hook
> with the line "locale hook".
> 
> thanks for you help.
> 
> -- 
> leonardo<http://pgp.mit.edu:11371/pks/lookup?op=get&search=0x24883F55141C1C5C>

So, this code takes a directory, $PROFILE_DIR, and loads all
executable files under hooks into bash.

-- 
Eduardo Alan Bustamante López



reply via email to

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