Age | Commit message (Collapse) | Author |
|
|
|
|
|
|
|
|
|
The "gratuitous extra entry" is only gratuitous when there isn't a hole. (Which
we can detect and not include but then we wouldn't match other implementations.)
|
|
|
|
|
|
|
|
|
|
(oops.)
|
|
length of sparse files properly.
|
|
|
|
|
|
(All ignored, because they disable stuff we don't do.)
|
|
|
|
Two more spacing bugs here, one before the security context for -Z, and
one after the size with --full-time.
Before:
$ ./toybox ls -lZ --full-time Config.
-rw-r----- 1 enh primarygroup? 56162019-09-07 21:09:32.892215100 -0700 Config.in
After:
$ ./toybox ls -lZ --full-time Config.
-rw-r----- 1 enh primarygroup ? 5616 2019-09-07 21:09:32.892215100 -0700 Config.in
|
|
I think when I wrote this I tested the named escapes like \n and hex
escapes, and when I found \x wasn't supported I didn't even think of
octal. And I only learned about \c when I was looking at echo and printf
to compare their escape implementations a few weeks back.
Add the missing escapes and corresponding tests.
Fixes #139.
|
|
This broke a netd test (but sadly in postsubmit rather than presubmit).
Also add a trivial test that would at least have caught this bug.
Bug: http://b/140453237
|
|
|
|
Commit c26870dab3462c6176936384b090df6b9ba46dee broke ls' error
reporting for files that don't exist. `ls $F` is used by some as an
equivalent of `test -e $F`.
This patch also adds a regression test.
|
|
This fixes the case where someone's done something (weird) like:
find src/*.c -name foo.c
Previously the match would fail because one side of the comparison was
already a path.
|
|
as unusual timestamp formats
After further research and testing, I've produced a patch which handles
all filenames with special characters by copying the GNU quoting
behavior, and also treats anything following a tab as a timestamp. This
increases both ability to handle possible filenames and ability to
apply patches found in the field.
In diff, quote and escape filenames according to the following rules.
* Surround the filename with quotes if it contains a byte less than 0x20,
a byte greater than or equal to 0x80, space, backslash, or quote.
* Replace alert, backspace, form feed, newline, carriage return, tab, vertical
tab, backslash, and quote with \a, \b, \f, \n, \r, \t, \v, \\, and \",
respectively.
* Replace other bytes less than 0x20 or greater than or equal to 0x80 with a
backslash followed by the three octal digits representing the value of the
byte.
* Treat valid UTF-8 characters involving sequences of bytes greater than or
equal to 0x80 the same as other sequences of such bytes.
In patch, process quoted and escaped filenames according to the following
rules.
* If the filename does not begin with a quote, do not modify the filename.
* Remove quotes surrounding the filename.
* In quoted filenames, replace \a, \b, \f, \n, \r, \t, \v, \\, and \" with
alert, backspace, form feed, newline, carriage return, tab, vertical tab,
backslash, and quote, respectively.
* In quoted filenames, replace a backslash followed by octal digits with the
byte with that value in octal.
Also, in patch, treat anything on a +++ or --- line following a tab character
after the beginning of the filename as a timestamp, rather than part of the
filename.
|
|
Unlike ls, find does treat ENOENT specially. Add an extra test (and fix
the behavior) for the case of ENOENT for a path provided on the command
line --- unlike other ENOENT cases (typically dangling symlinks), ENOENT
for a command line argument should report an error.
Also remove obsolete `|sed` from the symlink loop test.
|
|
The Linux kernel uses the --max-args synonym for -n.
Barbarians who use vi need xargs' -o to be able to do something like:
find -name xargs.c | xargs vi # Sad vi.
find -name xargs.c | xargs -o vi # Happy vi.
The -p option needs fixing to read from /dev/tty because stdin is
otherwise occupied in xargs. I think xargs is the only place that needs
this, so it didn't seem sensible to make all callers to yesno() be
specific about which they wanted, hence the new function.
Also remove the documentation for the build-time XARGS_PEDANTIC option
which isn't actually implemented.
Also add a TODO for -P (which is used by at least one script in the
Linux kernel).
|
|
Tweak DIRTREE_STATLESS so it returns zero stat for any error (I'm testing
that dev, ino, and blksize are all zero), and fill in file type from readdir()
|
|
macOS remains awkward, though, but this retains our Android/Linux
behavior and is closer to the platform's getconf(1) for macOS.
Strictly macOS denies all knowledge of UIO_MAXIOV, but the "undefined"
you'll get from this patch seems closer than the "1024" we used to
give.
|
|
Before:
$ ./rm
rm: Needs 1 argument
$ ./rmdir
rmdir: Needs 1 argument (see "rmdir --help")
After:
$ ./rm
rm: Needs 1 argument (see "rm --help")
|
|
The behavior with "\xAV" (where the second hex digit is invalid) is
different from the behavior with "\xVA", and echo and printf differ from
each other.
|
|
|
|
This was the last user of get_rawline, which lets us remove it.
|
|
ENOENT is ignored, but other errors are reported.
|
|
A TOYFLAG_NOFORK command must run in the context of toysh, but a MAYFORK
can either run standalone or run in the toysh process. MAYFORK means it
cleans up after itself: no leaked resources (malloc, mmap, filehandles, etc),
even in error_exit() paths that would longjmp() back to the shell. It also
doesn't discard anything we need to retain (don't close stdout, change
toys.optargs[] so we can't free it, etc)...
|
|
No current caller except grep needs this, but consistency seems like a
good idea.
Also change the xregcomp error message to be a bit more human-readable,
rather than mention an implementation detail.
|
|
We use (char *)1 and (char *)2 to indicate errors (they can never be valid
pointers because both malloc() and mmap() return aligned memory and those
align down to NULL, plus Linux maps 4k at the bottom to catch null
dereferences anyway), and then typecast it to long (trusting in LP64) to
do an integer <=2 comparison... except that needs to be UNSIGNED long or
else pointers in the top half of the virtual memory space become negative
and the <=2 false positives them as errors. (Oops.)
|
|
POSIX says there's no such thing as an empty regular expression. The
grammar excludes the possibility:
https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap09.html
BSD agrees with POSIX, and Android and macOS' BSD-based implementations
reject the empty regular expression.
GNU apparently disagrees.
Luckily, BSD does accept the empty *sub* expression `()`, despite their
error message for REG_EMPTY being "empty (sub)expression". This is
presumably a bug, except there's explicit code to support it that is at
least 26 years old:
https://github.com/freebsd/freebsd/blame/master/lib/libc/regex/regcomp.c#L383
This workaround also works fine with glibc.
If we want GNU behavior, I'm struggling to come up with another way to
fake it. If we want POSIX behavior, we could easily just add a check to
reject "" on glibc.
Also switch to xregcomp().
|
|
This was basically just to help me think out loud while discussing
loopfiles_lines().
|
|
I started this last night, but thought I'd aim to send multiple small
patches rather than work through all the callers and send one big patch.
I've deliberately chosen the ugly name `allocated_length` because we've
had historical bugs where folks think this a line length in the sense of
the return value. I do wonder whether we should actually have some kind
of getline() wrapper that hides the `char *`/`size_t` pair in lib/,
which makes the function easier to use in most cases but does add the
less common gotcha that you wouldn't be able to getline() through
multiple files at once (which does happen in at least one toy).
But maybe the real fix is to look harder for places where we can just
use loopfiles_lines? Speaking of which, should we actually add two more
arguments to that? Specifically: switch it to getdelim() rather than
getline() behind the scenes, and also add a way to have the trailing
'\n' automatically removed, since that seems to be what most callers
want?
Anyway, that seemed like enough questions that it was time to send this
initial patch out before doing too much more...
|
|
This was embarrassing... A build script that was using xargs -I silently
started to ignore -I when we switched over to toybox xargs. The owner of
the script has rewritten it to use the shell read builtin instead, but
it's pretty unhelpful to silently ignore an option that radically
changes how xargs behaves. (The -I behavior sounds sufficiently
different from normal behavior that I'm not sure I've understood, and am
just sending this cleanup rather than actually implementing -I correctly.)
Bug: http://b/137832162
|
|
|
|
The first bug appeared as a memory overwrite, but was actually visible
without hwasan: basically any `grep -F` that let to multiple matches on
the same line was broken.
The second bug was another memory overwrite, visible when I ran the
existing grep tests.
Bug: http://b/137573082
|
|
On BSD these are actually the same, and there's a -S that you need in
addition. So strictly this is a behavior change for Android (which is
going from BSD grep to toybox grep), but it's a behavior preserving
change for the AOSP build (which is going from GNU grep to toybox grep),
and the latter actually has a checked-in use of -R where the former
doesn't.
|
|
The other xargs implementations in the wild don't seem to count the
space taken by each `char *`. Go for bug compatibility unless future
experience proves that to be a bad idea.
|
|
Investigating why the toybox tar tests fail on Android with toybox dd, I
realized I was rewriting a part of dd I'd rewritten before!
This is a re-send of my 2019-02-22 patch, rebased against the current
ToT...
This patch was originally motivated because after suggesting to the author of
https://stackoverflow.com/questions/17157820/access-vdsolinux/54797221#54797221
that he could tell dd to work in bytes rather than blocks, I realized
that our dd doesn't actually support that. But the rewrite of the main
loop is necessary to fix the incorrect output from the dd calls in the
tar test.
Without this patch, `yes | dd bs=65536 count=1 > fweep` basically gives
random output, based on how many bytes the pipe feels like giving you in
your first read. (As far as I know, dd *without* bs= was fine, but I
can't guarantee that that's true, just that I haven't seen it fail.)
Also switch to TAGGED_ARRAY and comma_* for conv rather than add two more
copies of an undesired idiom. It turned out -- contrary to the belief of
cp(1) -- that comma_scan isn't suitable for this because of its magic
handling of "no" prefixes. (It's actually harmless in cp because none
of the --preserve options begin with "no", but some dd options do.) To
this end, comma_remove is a less-magic comma_scan.
I've also changed an `if` to a `while` because other implementations
allow things like `--preserve=mode,mode` or `conv=sync,sync`. (If we
decide this is a bug rather than a feature, we should at least fix the
error message to be clear that we're rejecting the *duplication*, not
the option itself.)
I've also fixed the ^C behavior by simply adding a direct SIGINT handler
rather than trying to be clever inside the read loop (which is why we
weren't handling the SIGINT until the read returned).
I've also removed `strstarteq` and just added the '=' to each literal
when calling regular `strstart`.
Plus basic tests.
|
|
"xz compressed data" was missing a newline. Also switch a couple of
other unnecessary (but correct) xprintf calls over to xputs.
Also add .otf fonts, perf/simpleperf data files, and Android boot
images, sparse images, and device tree blobs/overlays.
|
|
|
|
My app runs npm i -S better-sqlite3, and node-gyp-bin from the npm
upstream has #!/usr/bin/env sh, expecting the system shell.
|
|
Implement nl -v supporting negative and zero starting values.
|
|
file now shows the target of a symbolic link and calls out broken
symbolic links.
file now shows the device type for block/character special files.
file now shows specific reason when it can't open.
stat now includes the device type, plus a little more space between the
number of blocks and the human-readable file type.
Adjusted tests accordingly, which actually makes more of them pass on
the host as a convenient side-effect, but I actually made these changes
because I've been finding the desktop file and stat output more convenient
in these cases.
|
|
Used by build/make/tools/mktarball.sh in AOSP. (Which is why today's
switch to toybox tar got reverted.)
|
|
|