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

init: Fix error upon deleting file on non-GNU systems #658

Merged
merged 1 commit into from
Jul 30, 2023
Merged

init: Fix error upon deleting file on non-GNU systems #658

merged 1 commit into from
Jul 30, 2023

Conversation

lcook
Copy link
Contributor

@lcook lcook commented Jul 30, 2023

When passing arguments to xargs binaries can only be used, we cannot use a shells builtin command, so this issue cannot be subverted just by installing bash. In this instance, my systems printf implementation does not support the %q format specification—specifically a GNU extension. Yielding this error upon trying to delete a file:

printf: illegal format character q

For a more visual example;

navi:~
% uname ; man 1 printf | grep '%q' | wc -l
FreeBSD
       0
navi:~
% printf "%q\n" \f \oo 'bar'* baz
printf: illegal format character q
navi:~
% bash -c 'printf "%q\n" \f \oo 'bar'* baz '
f
oo
bar\*
baz

Remedying this is just a case of not using xargs and instead iterating through each line of the output pipe, then calling bash's builtin printf (oppose to an actual binary). While bash is still a hard requirement, this makes things less of a headache for new users on non-GNU-like system, in my case FreeBSD (to my understanding neither of the other BSD's support the %q format, seems to be another GNU-ism).

Retrospectively looking, I can only find xargs mentioned in the documentation;

% git grep 'xargs'
docs/en/src/awesome-hacks.md:            --preview="echo {}|sed 's#.*->  ##'| xargs exa --color=always" \
docs/en/src/awesome-plugins.md:[22]: https://github.com/sayanarijit/xargs.xplr

It might be worthwhile combing through the available plugins that may make use of xargs and GNU extensions.

Many thanks, and thank you for your continued work on xplr.

Closes: #652

@lcook lcook mentioned this pull request Jul 30, 2023
@sayanarijit
Copy link
Owner

sayanarijit commented Jul 30, 2023

Thanks for the fix with detailed explanation. I'll try to keep a bsd handy to test things before the next release.

I don't think I have used xargs in plugins other than xargs.xplr. still will check again.

@sayanarijit sayanarijit reopened this Jul 30, 2023
@sayanarijit
Copy link
Owner

Sorry mistakenly closed

@sayanarijit sayanarijit merged commit 6df168f into sayanarijit:dev Jul 30, 2023
20 checks passed
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.

Illegal format character q
2 participants