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

head: illegal line count on MacOS #4

Open
wodow opened this issue Sep 27, 2023 · 6 comments
Open

head: illegal line count on MacOS #4

wodow opened this issue Sep 27, 2023 · 6 comments

Comments

@wodow
Copy link

wodow commented Sep 27, 2023

A error from head appears with first use:

$ rgr foo -R bar
ACTUAL CONTENT WILL BE REPLACED IN YOUR FILESYSTEM.
If you'd like to do a dry-run instead, cancel the program and run with '-r' instead of '-R'.
Are you sure you'd like to continue? (Y or y to continue; any other key or just Enter to exit) y
head: illegal line count -- -9


real	0m0.037s
user	0m0.009s
sys	0m0.030s

This is using ripgrep v13 on MacOS 13.5.2.

@ElectricRCAircraftGuy
Copy link
Owner

ElectricRCAircraftGuy commented Sep 27, 2023

@wodow, does rg foo -r bar work for you? It does a dry run replacement without my wrapper.

I need to know for certain whether the problem is with ripgrep or with my rgr wrapper.

@wodow
Copy link
Author

wodow commented Sep 29, 2023

Yes, the dry run feature works ok.

I will try to debug by stepping through the script when next at a terminal.

@ElectricRCAircraftGuy
Copy link
Owner

ElectricRCAircraftGuy commented Sep 29, 2023

Before running the script, run set -x to turn on terminal command echo. When done, run set +x to turn it back off. Copy and paste the results so I can see which command is failing.

Also, try running other benign rg commands using rgr instead, to see if any other commands through my wrapper fail.

@wodow
Copy link
Author

wodow commented Sep 30, 2023

I'm not sure set -x is sufficient. It doesn't reveal anything new:

$ set -x
$ rgr foo -R bar
+ rgr foo -R bar
ACTUAL CONTENT WILL BE REPLACED IN YOUR FILESYSTEM.
If you'd like to do a dry-run instead, cancel the program and run with '-r' instead of '-R'.
Are you sure you'd like to continue? (Y or y to continue; any other key or just Enter to exit) y
head: illegal line count -- -9


real	0m0.031s
user	0m0.019s
sys	0m0.065s

still not tried stepping through -- will get to it

@wodow
Copy link
Author

wodow commented Oct 2, 2023

Is the problem as simple as POSIX standard head doesn't take negative numbers? See e.g. https://stackoverflow.com/a/60336903

@wodow
Copy link
Author

wodow commented Oct 2, 2023

On MacOS, GNU head is available from Homebrew, and by default installs as ghead. This accepts a negative num param, so replacing head in the script with ghead fixes the problem.

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