Skip to content

install.sh: Fix bee registery of /etc/files #343

Merged
merged 2 commits into from
Aug 24, 2023
Merged

Conversation

donald
Copy link
Collaborator

@donald donald commented Aug 24, 2023

The function install_etc_files contains a bug which causes the files in etc not to be probably registered in the crafted bee index of the "mxtools-0.0-0" package.

The reason is, that the functions install_exe and install_data are called from the last command of a pipeline. By default, this is executed in a subshell, so the implicit modification of the global variable INSTALLED_FILES is not seen by main process, which later uses it to generate the index.

Use the "lastpipe" shell option, which makes the last command of a pipeline run in the main shell process.

Copy link
Contributor

@pmenzel pmenzel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me.

@donald
Copy link
Collaborator Author

donald commented Aug 24, 2023

Which is better ?

shopt -s lastpipe
(cd etc ; find * -type f) | while read -r path; do
    if [[ -x etc/$path ]]; then
        install_exec etc/$path "$DESTDIR$sysconfdir/$path"
    else
        install_data etc/$path "$DESTDIR$sysconfdir/$path"
    fi
done

or

while read -r path; do
    if [[ -x etc/$path ]]; then
        install_exec etc/$path "$DESTDIR$sysconfdir/$path"
    else
        install_data etc/$path "$DESTDIR$sysconfdir/$path"
    fi
done < <(cd etc ; find * -type f)

@wwwutz
Copy link
Contributor

wwwutz commented Aug 24, 2023

I like the second version not using lastpipe . I have reasons. I have good reasons. Do I need reasons ? No. Because I like the second version.

@wwwutz
Copy link
Contributor

wwwutz commented Aug 24, 2023

whereas I don't like the *, it should at least be ./* .

@donald
Copy link
Collaborator Author

donald commented Aug 24, 2023

I like the second version not using lastpipe . I have reasons. I have good reasons. Do I need reasons ? No. Because I like the second version.

Ok, I take that one then.

whereas I don't like the , it should at least be ./

Correct, I'll fix it.

The function install_etc_files contains a bug which causes the files in
etc not to be probably registered in the crafted bee index of the
"mxtools-0.0-0" package.

The reason is, that the functions install_exe and install_data are
called from the last command of a pipeline. By default, this is executed
in a subshell, so the implicit modification of the global variable
INSTALLED_FILES is not seen by main process, which later uses it to
generate the index.

Make the loop run in the main shell process.
Although the local `etc` directory should contain only sane files, stick
to good habit and avoid `find *`, which misinterpretes filenames
starting with `-`. Also add quotes to avoid missinterpretation of
filenames with whitespace.
@donald donald merged commit b0f769c into master Aug 24, 2023
Sign in to join this conversation on GitHub.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants