Re: Sourcing a directory of of config files

From: Laurent Bercot <>
Date: Sun, 07 Jul 2024 21:46:49 +0000

>Have a directory "dir/", containing the files "a", "b" and "c", possibly more.
>Each file is filled with key=value lines.
>Is there an elegant way to source all the files in "dir/" into environment variables of key=value, without writing to a temporary file and sourcing that at the end?

  "cat * | envfile -" ?
  The problem you'll need to solve is this one:

>If "a" and "b" both contain the same key, the value in "b" should overwrite that in "a", but that is probably immanent anyway.

  If you have duplicates, you'll want to determine a sorting order for
the files. If you're happy with regular alphanumeric sorting, then
something like this should work (untested)

(using a loop instead of elglob because cat * won't behave correctly
if dir is empty)

importas dir 1
emptyenv -c
   forbacktickx -E -d"\n" file { ls -1 ${dir} }
   cat ${dir}/${file}
envfile -

Received on Sun Jul 07 2024 - 23:46:49 CEST

This archive was generated by hypermail 2.4.0 : Sun Jul 07 2024 - 23:47:19 CEST