jarun / nnn

n³ The unorthodox terminal file manager
BSD 2-Clause "Simplified" License
19.18k stars 760 forks source link

Add support for busybox #384

Closed BKPepe closed 4 years ago

BKPepe commented 4 years ago

Someone requested to have nnn in OpenWrt, there is preinstalled busybox, which provides several utilities. One of these utilities is xargs, which does not have the option a.

xargs: unrecognized option: a
BusyBox v1.30.1 () 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 NULs
    -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
    -x    Exit if size is exceeded

Because of that, there needs to be installed coreutils-xargs. Other things like copy, move, rm works with provided tools by busybox. It would be good if it can use just busybox utilities.

Environment details (Put x in the checkbox along with the information)

[x] Operating System: OpenWrt

jarun commented 4 years ago

Please test with the patch and confirm.

@KlzXS can you please review the changes thoroughly? I am extremely worried about dropping the -o.

BKPepe commented 4 years ago

That's was fast! Thanks. I will try it and let you know.

KlzXS commented 4 years ago

Immediately I can see that it no longer asks me if I want to overwrite files, which could be a bit of a problem. I say that we should keep -o. There is -p but that's a bit too much.

Other than that files are still copied, moved and removed like they were. Maybe get someone to test the trash feature, I don't think I have that setup. I'll test it more in depth later if we decide to go ahead with this, but I'm also unsure about dropping -o.

BKPepe commented 4 years ago

Now, it shows: xargs: unrecognized option: I

jarun commented 4 years ago

@KlzXS and @BKPepe

I have reverted the earlier patch. The indicative code is in git history still. I can't break a utility working perfectly on tons of platforms because one platform can't install findutils. The changes are extremely risky and I can't get these tested on multiple platforms immediately.

I can think of the following alternatives:

jarun commented 4 years ago

@BKPepe with PR #388 we are on for BusyBox! Please test and confirm if everything works.

The credit for this goes to @KlzXS!

BKPepe commented 4 years ago

I will take a look at it. Thanks!

BKPepe commented 4 years ago

I've just tested it and works. Good work!

jarun commented 4 years ago

Thanks for confirming! I'm closing the defect. Please feel free to let us know if you need anything else in nnn.