fix(scripts): handle unset gpu_device_flag array safely#187
fix(scripts): handle unset gpu_device_flag array safely#187ericcurtin merged 1 commit intodocker:mainfrom
Conversation
This syntax only expands the array if it's set and non-empty, avoiding the "unbound variable" error when the array is empty. Signed-off-by: Dorin Geman <dorin.geman@docker.com>
There was a problem hiding this comment.
Pull Request Overview
This PR fixes a bash scripting error that occurs when the gpu_device_flag array is empty, preventing the "unbound variable" error in the docker-run script.
- Uses safe array expansion syntax to handle empty arrays without causing script failures
- Ensures the docker run command executes successfully even when no GPU devices are detected
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
Reviewer's guide (collapsed on small PRs)Reviewer's GuideIntroduces a conditional expansion guard for the gpu_device_flag array in docker-run.sh to prevent unbound variable errors when the array is empty. File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
Summary of ChangesHello @doringeman, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request resolves an issue in the Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Hey there - I've reviewed your changes - here's some feedback:
- Consider initializing gpu_device_flag as an empty array (e.g.,
declare -a gpu_device_flag=()) at the top of the script to avoid unbound variable checks. - For readability, you could wrap the GPU flags in an explicit if-statement checking array length instead of using the parameter expansion hack.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- Consider initializing gpu_device_flag as an empty array (e.g., `declare -a gpu_device_flag=()`) at the top of the script to avoid unbound variable checks.
- For readability, you could wrap the GPU flags in an explicit if-statement checking array length instead of using the parameter expansion hack.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
There was a problem hiding this comment.
Code Review
This pull request correctly fixes a potential 'unbound variable' error in the docker-run.sh script that can occur when set -u is enabled and the gpu_device_flag array is empty. The change uses an idiomatic bash parameter expansion to safely handle this case. The fix is effective and targeted. I have one suggestion to improve the maintainability of the code.
This syntax only expands the array if it's set and non-empty, avoiding the "unbound variable" error when the array is empty.
Follow-up to #171 which can make
make docker-runfail:Summary by Sourcery
Bug Fixes: