aboutsummaryrefslogtreecommitdiff
path: root/toys
AgeCommit message (Collapse)Author
2020-03-05Fix 'for i in one two three; do echo =$i=; done'Rob Landley
2020-03-03Remove another command sub-option.Rob Landley
The question "how does this toybox command behave" should have an answer, not "it depends". (Also, --preserve at the start of a paragraph was confusing config2help.c into thinking it was an option paragraph.)
2020-03-02Switch to FLAG() macros.Rob Landley
2020-03-02Merge realpath into readlink, use xabspath() instead of libc realpath().Rob Landley
2020-03-02Work around gcc trying to be "helpful" again.Rob Landley
2020-03-01readelf: various fixes.Elliott Hughes
Add -e, and stop documenting no-op -W. Fix sign issues, and add a few extra sanity checks. Redo the BE/LE 16/32/64 reading. Remove the NOSPACE=1 from the -l test, and fix the -l code to match the binutils output. Most usefully, this fixes the weird way the NULL section's empty name would cause misalignment in the section to segment mapping output. Add a test for -s (symbol table).
2020-03-01Snapshot of variable resolution implementation. Not remotely load bearing yet.Rob Landley
2020-02-28vi: Rearrange functions, add o, O, IJarno Mäkipää
Place function calls in order so that there is no unneeded declarations, clear some whitespace stuff. Add few commands that are commonly used. cleanup: reorganize functions cleanup: some whitespace stuff add: vi_o vi_O vi_I fix: stop at edges when h and l fix: fix dd not updating screen fix: render after all delete moves
2020-02-28Some compilers get upset if ? : produces different types.Rob Landley
2020-02-27chattr: allow `chattr =`.Elliott Hughes
Also fix another bug where we were testing `set` twice. Fixes https://github.com/landley/toybox/issues/172.
2020-02-26Fix bugs reported by anatasluo: min/range/max were out of order,Rob Landley
min/max weren't being calculated, only print summary when we recieved at least one reply packet. And switch to FLAG() macros.
2020-02-25ps: widen pid_t fields.Elliott Hughes
My desktop and laptop have a pid_max of 262144 now.
2020-02-24Fix fuzz to output lines that didn't match patch context.Rob Landley
(It was outputting the patch hunk where it went, which reverted the context.)
2020-02-11Fix wget version concat segfault.Denys Nykula
2020-02-11chattr: fix exit status, redo the tests.Elliott Hughes
The e2fsprogs chattr(1) returns failure when it fails to do what was asked of it, and so should we. Fixing this then reveals a lot of issues with the tests that were being accidentally swept under the carpet. The bulk of this patch is going through all the tests, removing the duplicates and making the remaining tests more thorough. I've tested this on ext4 and f2fs on a variety of 4.x and 5.x kernel versions (but nothing older). We might need to reduce the list of attribtues we try to toggle, but the more thorough tests use well-supported attributes. I've also fixed the -R test to actually involve a directory hierarchy.
2020-02-06vi: fix pointer pos when at end of lineJarno Mäkipää
Going to $ made draw_page render cursor to wrong line
2020-02-06Basic parenthetical subshell support.Rob Landley
2020-02-06chattr: improve error messages.Elliott Hughes
When chattr fails in production, it helps to see what it was trying to do. Reuse the lsattr format but without the '-'s. Only read the flags if we have any intention of changing them: `chattr -p 123` has no reason to read the flags. Only write the flags back if they actually change: `chattr +a` shouldn't do anything if that flag is already set, for example. Switch -p and -v to perror_msg() instead of perror_exit() in case they're used with -R. (I suspect that the uses of DIRTREE_ABORT are mistakes given -R, but I'll leave them until I actually hit this.)
2020-02-06Remove old GNU style `' quoting.Elliott Hughes
Even GNU don't pretend they're still on 1970s terminals where ` and ' were a matching pair any more.
2020-02-05chattr: reuse toybox argument parsing.Elliott Hughes
Rewrite -v and -p to not use ad hoc argument parsing.
2020-02-04More (subshell) work (not finished), fix {block;} | pipes.Rob Landley
2020-02-03readelf: support large ELF64 files on LP32 systems.Elliott Hughes
2020-02-03vi: fix 32-bit build.Elliott Hughes
2020-02-02vi: Replace linelist with Piece table based designJarno Mäkipää
Replaced dlist linelist with continuous memory blocks. This will allow editing huge files without billion mallocs. File is first opened with mmap() and mapped region is fully described in block_list as one block. Currently "valid" data is described as slices, when first loading file there is only one slice that points to memory existing in block_list. When cutting text, block_list is not freed or modified, but instead slice_list is modified to have "hole" between 2 slices. when inserting new mem_block is added, previos slices are cut in cursor position and new slice is added... Added functions to handling data inside block_list+slice_list insert_str(), cut_str() are used for all delete and add operations text_strrchr(), text_strchr() are used for searching lineendings text_byte(), text_codepoint(), text_getline() are for simple data access Implemented: more or less all previous functionality Implemented more proper file write: file is saved to .swp, blocks are unloaded, file permissions are copied, and atomic rename is called, block is reloaded chmod some defaults(rw-rw-r--) if original file could not be fstat (does not exist) FIX make all tests pass Removed: Some unused functions
2020-02-02Canonicalize the usage: lines for the POSIX toys.Elliott Hughes
This only touches 24 of the 68 toys/posix/ files --- the others were already canonical. Potentially contentious, so worth stating explicitly, is that there were 8 matches for "COMMAND..." amongst all existing help output, with 7 matches for various inconsistent variants involving something with "ARG", so I resolved that in favor of using "COMMAND..." (which is also shorter overall, and avoids nested []s).
2020-02-02mount.c: fix an error check.Elliott Hughes
Found by GCC 9: toys/lsb/mount.c:188:22: warning: '%s' directive argument is null [-Wformat-overflow=]
2020-02-01Auto-initialize variables, some of which are readonly and some exported.Rob Landley
2020-02-01lsattr/chattr: improve help text.Elliott Hughes
Document all the attributes, and take less space doing so. Switch to CAPITALS for user input in the synopses. Don't imply that this is only for ext2 (but also don't try to list the subset of file systems that do support which subset of attributes).
2020-01-30Move TOYBOX_VERSION fallback definition to toys.h.Rob Landley
(A git build takes it from "git describe".)
2020-01-30Couple more tests and sh comment changes. (Mostly todo list tracking.)Rob Landley
2020-01-29Quick and dirty "echo $ABC" support, done totally the wrong way, but itRob Landley
makes those two remaining tests pass.
2020-01-28David Legault complained that dir/.* tells rm to delete dir/.. and we'd do it.Rob Landley
2020-01-26Add mayfork to printfRob Landley
2020-01-26Implement nommu subshell plumbing, <(command), and fix 2>&1Rob Landley
2020-01-25vi: Add testsJarno Mäkipää
Test file integrity after load, move, delete and save+exit. Drawing of buffer is not tested yet. Added -s script option, accept file that is run as startup script of commands. File is parsed byte at time and handled as you had typed it. If EOF has been reached without editor close command, editing is continued normally using keyboard. This functionality is in vim and neovim, but not in POSIX vi standard. nvi (vi used in some macs) has -s with different meaning... Some simple tests added, dw last line test fails, so test is disabled.
2020-01-24cp/mv: add -T.Elliott Hughes
The kernel script scripts/kconfig/merge_config.sh uses cp -T. (Also sort the options into alphabetical order while adding -T, so that eyeball binary search actually works when trying to find an option! Oddly, they all show in reverse order because there's a bug in the help text generator, but that's a problem for another day...)
2020-01-22lsattr/chattr: -p support.Elliott Hughes
Add support for setting projid in chattr, and dumping it in lsattr. Also fix the lsattr output formatting, and undo my well-intentioned sorting of the flags because that broke the ordering in the lsattr terse output.
2020-01-20lsattr/chattr: add missing flags.Elliott Hughes
Also update help to include flags that were already added. Remove useless duplicative comments. Swich to FLAG macros.
2020-01-20cal: highlight current day.Elliott Hughes
This isn't in POSIX, but Debian and macOS' cal(1)s both do this, and it's annoying to have to run date(1) separately.
2020-01-15vi: fixes and small cleanupJarno Mäkipää
fix: first line delete fix: delete with e move fix: statusline 1 row lower, remove eol cleanup: use dlist_pop on delete cleanup: move globals into GLOBALS
2020-01-14vi: don't exit on ^C or ^D.Elliott Hughes
^D is the opposite of ^U in vi (the ^D/^U pair is the half-screen version of ^F/^B). ^C is unbound in vi. It's pretty surprising for these to cause toybox vi to exit, and it's annoying as long as toybox vi unconditionally exits rather than checks whether there are unsaved modifications! (I'm tempted to implement ^D/^U and ^F/^B, but I don't want to make Jarno's rebase of his in-progress changes any harder.)
2020-01-11Fix a duplicate free() and a variable stomp, set s=s to fix "can never beRob Landley
used uninitalized" warning, move flow control character detection to the right place, change scratch zeroing to the same way main() does it.
2020-01-11sh.c: fix memory corruption due to uninitialized sh_function in sh_runRich Felker
2020-01-11find.c: don't assume time_t is the same as longRich Felker
This is false on ILP32 targets with 64-bit time_t.
2020-01-10setsid: document -w.Elliott Hughes
-w was added recently. The change in behavior so we now always fork means that it's needed in more cases too: other implementations of setsid(1) only fork if getpgrp() != getpid(). This broke a script, which is what made me notice the missing help. This seems to have been an accidental change, and is contrary to what the util-linux setsid(1) man page says: "The command calls fork(2) if already a process group leader. Otherwise, it executes a program in the current process", but whether we change our behavior or not, we should document the new option.
2020-01-10readelf.c: fix 32-bit.Elliott Hughes
All of this was fine on LP64 where `long` and `long long` are the same length, but breaks the LP32 build with -Wformat.
2020-01-10sntp.c: fix 32-bit.Elliott Hughes
The epoch was being defined as UL, which is fine for LP64, but too small on LP32 for what we're trying to do. toys/net/sntp.c:60:32: warning: left shift count >= width of type return ((tv.tv_sec+SEVENTIES)<<32)+(((long long)tv.tv_nsec)<<32)/1000000000; ^~ (Android doesn't use this, I'm just fixing this too while I fix the LP64isms I introduced in readelf...)
2020-01-09readelf: RELR (both new and historical).Elliott Hughes
The "historical" variant is still the only one in use on Android right now. We still need to switch to the numbers we agreed on with the other System V ABI users. See https://groups.google.com/g/generic-abi/c/bX460iggiKg for the original discussion on RELR.
2020-01-09vi: fix warnings, improve status display.Elliott Hughes
mbtowc(0, 0, 4) is weird, and ignoring the result is weird. Avoid all this by just reusing the toybox lib utf8 functions. Also fix the row/column display on the status line to count from 1 and correctly distinguish bytes and characters in non-ASCII, and change the mode output to only explicitly say when we're in insert mode, in the same way that vim does. (Every time I saw the old blue-on-black text for COMMAND I thought toybox vi had crashed!)
2020-01-09ls.c: just use getxattr()/lgetxattr().Elliott Hughes
bionic works around the fact that you can't use an O_PATH fd with fgetxattr(2), but glibc doesn't. Fixes https://github.com/landley/toybox/issues/158.