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

Remove bash trace and manage unbound var #6

Merged
merged 1 commit into from
Mar 15, 2024

Conversation

jpinsonneau
Copy link
Contributor

@jpinsonneau jpinsonneau commented Mar 15, 2024

Since functions.sh is called from oc commands, we need to adapt the scripts to ensure variables are bound.

Else the scripts simply crash when filters are not set:

$ oc netobserv packets
/usr/local/bin/oc-netobserv-packets: line 5: $1: unbound variable

Also removed trace since it makes difficult to read the custom messages that are supposed to guide you.

echo "Filters not set"
else
echo "Filters set as $1"
filter=$1
Copy link
Contributor

Choose a reason for hiding this comment

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

Why u set it again?

Copy link
Contributor Author

@jpinsonneau jpinsonneau Mar 15, 2024

Choose a reason for hiding this comment

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

I don't set it directly:

  • Line 5 to avoid bash to fail if not set
  • Line 7 checks if the variable exists without failing
  • Line 12 set the variable (only if it exists)

Copy link
Contributor

Choose a reason for hiding this comment

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

/lgtm

@jpinsonneau jpinsonneau merged commit ee1b3b8 into netobserv:main Mar 15, 2024
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.

2 participants