[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Good placement of bash export functions
From: |
Greg Wooledge |
Subject: |
Re: Good placement of bash export functions |
Date: |
Tue, 11 Oct 2022 16:52:46 -0400 |
On Tue, Oct 11, 2022 at 05:51:57PM +0000, uzibalqa wrote:
> I have a number of bash script files that perform a specific tasks. After
> defining the appropriate set of functions, I included an additional utility
> function that allows one to export the function names.
Why are you exporting the functions at all? Do you run a complicated
find command, with -exec bash -c '....' which uses one of the functions?
You call these "script files". A script is normally a command implemented
in bash. It's got a shebang (#!/bin/bash or equivalent), and it lives in
a directory in your $PATH, and you run it as a command, by typing its
name in a shell.
When it runs, it does so as a separate child process. Therefore,
exporting a function has no effect on the calling shell.
> What would be easier to use, an export function in every file, or having a
> separate file containing all the necessary export functions for the entire
> package?
... "package"?
What are you trying to do here?
How do you actually run these "script files"?
What's the intent behind exporting the functions?