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

test just doc update #40

Merged
merged 2 commits into from
Sep 13, 2024
Merged

test just doc update #40

merged 2 commits into from
Sep 13, 2024

Conversation

hossain-khan
Copy link
Owner

No description provided.

To prevent the command from exiting the script and instead return the result so that you can continue checking other conditions, you can capture the exit status of the `grep` command using `$?` and store it in a variable.

Here's how you can modify your code:

```sh
echo "$CHANGED_FILES" | grep -Ev '^apilib/docs/.*\.md$' > /dev/null
grep_exit_status=$?

# Now you can use the value of `grep_exit_status` to continue your script
if [ "$grep_exit_status" -eq 0 ]; then
    echo "There are files outside of 'apilib/docs/*.md'."
else
    echo "No files outside of 'apilib/docs/*.md' or no files in CHANGED_FILES."
fi

# You can continue other checks here based on the value of `grep_exit_status`
```

### Breakdown:
- `> /dev/null`: Redirects the `grep` output to nowhere since you are only interested in the exit status.
- `$?`: Captures the exit status of the last command (`grep` in this case) and stores it in the variable `grep_exit_status`.
- The `if` block then checks the value of `grep_exit_status` to decide further actions without terminating the script.

This way, your script won't exit, and you can handle the return value for other checks.
@hossain-khan
Copy link
Owner Author

To prevent the command from exiting the script and instead return the result so that you can continue checking other conditions, you can capture the exit status of the grep command using $? and store it in a variable.

Here's how you can modify your code:

echo "$CHANGED_FILES" | grep -Ev '^apilib/docs/.*\.md$' > /dev/null
grep_exit_status=$?

# Now you can use the value of `grep_exit_status` to continue your script
if [ "$grep_exit_status" -eq 0 ]; then
    echo "There are files outside of 'apilib/docs/*.md'."
else
    echo "No files outside of 'apilib/docs/*.md' or no files in CHANGED_FILES."
fi

# You can continue other checks here based on the value of `grep_exit_status`

Breakdown:

  • > /dev/null: Redirects the grep output to nowhere since you are only interested in the exit status.
  • $?: Captures the exit status of the last command (grep in this case) and stores it in the variable grep_exit_status.
  • The if block then checks the value of grep_exit_status to decide further actions without terminating the script.

This way, your script won't exit, and you can handle the return value for other checks.

@hossain-khan hossain-khan merged commit 0ccc600 into master Sep 13, 2024
1 of 2 checks passed
@hossain-khan hossain-khan deleted the doc-5 branch September 13, 2024 00:17
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.

1 participant