[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Good placement of bash export functions
From: |
uzibalqa |
Subject: |
Re: Good placement of bash export functions |
Date: |
Tue, 11 Oct 2022 21:06:13 +0000 |
------- Original Message -------
On Tuesday, October 11th, 2022 at 8:52 PM, Greg Wooledge <greg@wooledge.org>
wrote:
> 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"?
A have a number of bash script files, each with its own set of functions that a
user can call.
Each files focuses on specific tasks (for instance. comint.rc handles parallel
versions of
search for both find and grep). So I call the whole collection a terminal
shell "package".
> What are you trying to do here?
>
> How do you actually run these "script files"?
I source the files. Then users can just call the functions they want, without
having to worry
about specifying any paths.
> What's the intent behind exporting the functions?
It is a facility, normally one does not call the export functions. But one can
call them if one wants.