rmyorston / busybox-w32

WIN32 native port of BusyBox.
https://frippery.org/busybox
Other
694 stars 126 forks source link

Support -- everywhere please #309

Open ale5000-git opened 1 year ago

ale5000-git commented 1 year ago

Quote from a message at https://bugs.busybox.net/show_bug.cgi?id=15466:

POSIX will be standardizing realpath in Issue 8:
https://www.austingroupbugs.net/view.php?id=1457

As such, the standard requirements that all utilities not explicitly excluded (basically, echo is one of the few explicit exceptions) MUST accept -- as end-of-options, even when the standard does not require any standardized options.  Once Issue 8 is out,

realpath /tmp
realpath -- /tmp

must have identical behavior.  Busybox 1.35 (I tested the pre-built version available on Fedora 37) fails this:

$ busybox realpath -- /tmp
realpath: --: No such file or directory
/tmp

I'm sure most cases will be fixed upstream but it would be nice also if you support it also in utilities that are specific of BusyBox for Windows.

ale5000-git commented 1 year ago

If possible it will also be nice to support:

-n
    Do not print a trailing newline character.

on cut.

This is one that I really need.

rmyorston commented 1 year ago
-n
   Do not print a trailing newline character.

Where are you seeing that? On my system cut in coreutils has:

-n                      with -b: don't split multibyte characters
avih commented 1 year ago

-n Do not print a trailing newline character.

TBH I don't think this is particularly useful. Most commands do add \n, so dealing with that systematically and correctly is something you should be doing anyway - everywhere, so I don't think such non-portable flag is very useful.

Also, this doesn't solve the case where the value ends in newline[s]. So the difference between dealing with that with or without a single additional newline adds exactly one char to the code.

ale5000-git commented 1 year ago

After reading more carefully it is just my misunderstanding, I just mixed in my head these two:

POSIX will be standardizing realpath in Issue 8:
https://www.austingroupbugs.net/view.php?id=1457
As such, the standard requirements that all utilities not explicitly excluded (basically, echo is one of the few explicit exceptions) MUST accept -- as end-of-options, even when the standard does not require any standardized options.

and

POSIX will be standardizing readlink (just the -n option) ...
Change things for readlink so that the POSIX-mandated -n and -- work
even when disabling the non-standard (and partially non-working) -f
when FEATURE_READLINK_FOLLOW is clear

@avih: It is very useful to optimize performance, to remove the newline I have to either pipe the result of cut to tr or use command substitution. If I have to execute them a lot of times it will be a lot slower than just a parameter.

ale5000-git commented 1 year ago

These in particular have issues:

drop -- whoami
realpath -- .