Skip to content

[Discussion] Improvements to distrobox-export --bin #797

@Scafir

Description

@Scafir

Hi,

Following the discussion with @fredizzimo in #651, I think that it is best to discuss how to tackle the exported binaries.

First of all, let me write down the goal (in my opinion) that we should strive for with binaries export:
"Exported binaries should produce the same result than the same command run from inside the distrobox"

To reach this goal, I suggest using a login shell by default, as not using it may only cause hard to debug issues, with no clear advantage.
I would also argue that using a login shell and executing the command within that also solve an issue raised in the original merge request: in what shell should the command be run?
There are three level to this:

  1. What shell interprets the arguments given? (globbing, etc) -> the shell from which the exported binary is called
  2. What shell actually executes the exported binary? -> ??
  3. What is the $SHELL present while executing the exported binary? -> the default shell set inside the distrobox

I would argue that number 2 is not actually important, as no matter the shell, the end result should be the same.
This allows us to use a single shell for all use case inside the exported script. This is a big advantage over using $SHELL, as it allows us to avoid having to determine what syntax should be used (e.g: fish does not use $@).

Being careful avoiding issues with binary files that may not be executed with a simple sh -l myBinaryFile, we would get a end result along the lines of:

distrobox-enter ${rootful} -n  myDistrobox -- ${is_sudo} sh -lc 'path/to/command "$@"' command ${extra_flags} "$@"

I will most likely submit a merge request for this, do not hesitate to let me hear your thoughts.

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionFurther information is requested

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions