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

Grep on BusyBox #1

Open
televisi opened this issue Feb 6, 2024 · 3 comments
Open

Grep on BusyBox #1

televisi opened this issue Feb 6, 2024 · 3 comments

Comments

@televisi
Copy link

televisi commented Feb 6, 2024

Hi

This is not an issue but more a discussion.

Great script! I wonder whether there is a way to update the script so that it can run from within the borgmatic docker instance - which most likely is using busybox.

When I tried to run the script from within borgmatic docker, it threw this error:

$ ./borg-consciousness.sh 
grep: unrecognized option: invert-match
BusyBox v1.36.1 (2023-07-27 17:12:24 UTC) multi-call binary.

Usage: grep [-HhnlLoqvsrRiwFE] [-m N] [-A|B|C N] { PATTERN | -e PATTERN... | -f FILE... } [FILE]...

Search for PATTERN in FILEs (or stdin)

        -H      Add 'filename:' prefix
        -h      Do not add 'filename:' prefix
        -n      Add 'line_no:' prefix
        -l      Show only names of files that match
        -L      Show only names of files that don't match
        -c      Show only count of matching lines
        -o      Show only the matching part of line
        -q      Quiet. Return 0 if PATTERN is found, 1 otherwise
        -v      Select non-matching lines
        -s      Suppress open and read errors
        -r      Recurse
        -R      Recurse and dereference symlinks
        -i      Ignore case
        -w      Match whole words only
        -x      Match whole lines only
        -F      PATTERN is a literal (not regexp)
        -E      PATTERN is an extended regexp
        -m N    Match up to N times per file
        -A N    Print N lines of trailing context
        -B N    Print N lines of leading context
        -C N    Same as '-A N -B N'
        -e PTRN Pattern to match
        -f FILE Read pattern from file

If that is not possible, all good, I'll find another Linux box to run the check.

Thanks

@jeffmakes
Copy link
Owner

Thanks! It looks like that BusyBox version of grep doesn't support options in --written-like-this format, only single letters. From the grep man page:

       -v, --invert-match
              Invert the sense of matching, to select non-matching lines.

You can replace --invert-match in the script with -v. If that fixes works ok, feel free to submit a PR.

Cheers

@televisi
Copy link
Author

televisi commented Feb 7, 2024

You can replace --invert-match in the script with -v. If that fixes works ok, feel free to submit a PR.

Thanks! I've done my first pull request; hopefully it works okay.
I also added "BORG_RSH" variable too

@jeffmakes
Copy link
Owner

Great, thanks, merged. I tweaked it to always use -v, for compatibility everywhere.

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

No branches or pull requests

2 participants