Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

host-exec: Fix CONTAINER_ID: unbound variable error #888

Merged
merged 2 commits into from
Aug 3, 2023

Conversation

luc14n0
Copy link
Contributor

@luc14n0 luc14n0 commented Aug 3, 2023

Currently the script sets the nounset shell option, but it doesn't define the CONTAINER_ID variable and nor it should (something else does it). In such cases, we should resort to shell parameter expansion in order to use a default value (an empty string, in this case) if the parameter - read CONTAINER_ID variable - is unset or null.

So, we should use ${CONTAINER_ID:-} instead, to avoid this error.

Fixes #882

luc14n0 added 2 commits August 2, 2023 20:39
Currently the script sets the nounset shell option, but it doesn't
define the CONTAINER_ID variable and nor it should (something else does
it). In such cases, we should resort to shell parameter expansion in
order to use a default value (an empty string, in this case) if the
parameter - read CONTAINER_ID variable - is unset or null.

So, we should use "${CONTAINER_ID:-}" instead, to avoid this error.

Fixes 89luca89#882

Signed-off-by: Luciano Santos <luciano.santos@email.com>
Use "download_command" instead, and initialize it in the top of the
script (download_command=""). This should avoid "unbound variable"
errors in unfortunate cases where curl nor wget are found, and the
variable would remain unset.

Signed-off-by: Luciano Santos <luciano.santos@email.com>
@89luca89
Copy link
Owner

89luca89 commented Aug 3, 2023

Thanks a lot for the fix @luc14n0 😄

@89luca89 89luca89 merged commit 3665801 into 89luca89:main Aug 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Error] distrobox-host-exec gives CONTAINER_ID: unbound variable on Arch Linux
2 participants