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

xargs seems to be consuming stdin #934

Closed
jarun opened this issue Nov 28, 2018 · 9 comments
Closed

xargs seems to be consuming stdin #934

jarun opened this issue Nov 28, 2018 · 9 comments

Comments

@jarun
Copy link

jarun commented Nov 28, 2018

While trying to read some filenames from a file and removing them interactively, xargs seem to be consuming stdin. So the interactive mode doesn't work:

u0_a117@localhost ~/G/nnn> xargs -0 -a ~/.nnncp rm -ir
rm: remove '/data/data/com.termux/files/home/GitHub/nnn/nnn'? ⏎                                            u0_a117@localhost ~/G/nnn>

u0_a117@localhost ~/G/nnn> xargs -0 -a ~/.nnncp rm -ir
rm: remove '/data/data/com.termux/files/home/GitHub/nnn/CHANGELOG'? rm: remove '/data/data/com.termux/files/home/GitHub/nnn/LICENSE'? rm: remove '/data/data/com.termux/files/home/GitHub/nnn/Makefile'? ⏎
u0_a117@localhost ~/G/nnn>

However, as the input is from a file (using option -a) this should work as it does on all Linux (Tested on Ubuntu and the Linux subsystem for Windows).

@ghost
Copy link

ghost commented Nov 28, 2018

@jarun Have you tried to use the following command ? (with -d '\n')

xargs -0 -a ~/.nnncp -d '\n' rm -ir

@Grimler91
Copy link
Member

And are you using xargs from the package findutils or from busybox?

@jarun
Copy link
Author

jarun commented Nov 28, 2018

I have installed the Termux app from Google Play. So it's the default one.

@jarun
Copy link
Author

jarun commented Nov 28, 2018

Yes, it seems to be the one from BusyBox:

u0_a117@localhost ~/G/nnn> xargs -h
xargs: invalid option -- h
BusyBox v1.29.2 (2018-08-30 09:16:36 UTC) multi-call binary.

Usage: xargs [OPTIONS] [PROG ARGS]

Run PROG on every item given by stdin

	-p	Ask user whether to run each command
	-r	Don't run command if input is empty
	-0	Input is separated by NUL characters
	-a FILE	Read from FILE instead of stdin
	-t	Print the command on stderr before execution
	-e[STR]	STR stops input processing
	-n N	Pass no more than N args to PROG
	-s N	Pass command line of no more than N bytes
	-I STR	Replace STR within PROG ARGS with input line
	-P N	Run up to N PROGs in parallel
	-x	Exit if size is exceeded
u0_a117@localhost ~/G/nnn>

@jarun
Copy link
Author

jarun commented Nov 28, 2018

Yes, the one from findutils fixes this. Thanks you!

@jarun
Copy link
Author

jarun commented Nov 28, 2018

@fornwall can we have findutils as a dependency for nnn? It would make cp, mv, rm work on Termux.

@jarun
Copy link
Author

jarun commented Nov 28, 2018

@xeffyr I saw your question now. That won't work as my strings are NUL-terminated. There's no LF as filenames can have LF.

@jarun
Copy link
Author

jarun commented Nov 28, 2018

Thanks for the PR @xeffyr!

fornwall pushed a commit to termux/termux-packages that referenced this issue Nov 29, 2018
@fornwall
Copy link
Member

The updated package (version 2.1-1) which requires findutils is now available for installation!

@ghost ghost locked and limited conversation to collaborators Oct 17, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants