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: invalid option -- P #2023

Closed
JonasGoetz01 opened this issue Mar 30, 2022 · 3 comments
Closed

grep: invalid option -- P #2023

JonasGoetz01 opened this issue Mar 30, 2022 · 3 comments

Comments

@JonasGoetz01
Copy link

Actual behavior
When trying to grep some content during a ci pipeline I get this error:

grep: invalid option -- P
BusyBox v1.32.0 (2020-12-03 00:49:17 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

Expected behavior
the grep command should get the version number out of a specific file

To Reproduce
Steps to reproduce the behavior:

  1. Start a CI/CD pipeline with the latest gcr.io/kaniko-project/executor:debug image
  2. Use a grep -Pzo command like provided later.

Additional Information

  • Dockerfile
    There isn't a specific Dockerfile needed to reproduce that error.

Example File
Example yaml

version/number:22.3.1

Example grep command inside the pipeline

grep -Pzo 'version/number:(.)*' example-file.yml | cut -d ":" -f 2
Description Yes/No
Please check if this is a new feature you are proposing
Please check if the build works in docker but not in kaniko
Please check if this error is seen when you use --cache flag
Please check if your Dockerfile is a multistage Dockerfile
@imjasonh
Copy link
Collaborator

Did this work in a previous version of Kaniko?

This sounds like busybox (which Kaniko's :debug image is based on to provide a shell and userspace) doesn't support grep -P. I'm not sure there's a lot we can do about it, unless this is a recent regression.

@JonasGoetz01
Copy link
Author

No I don't know if that worked in an earlier version

@imjasonh
Copy link
Collaborator

Thanks, that's helpful to know.

In that case, I think this is working as intended -- the :debug image is based on busybox, which supports certain options for grep, of which -P is not one.

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