aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorElliott Hughes <enh@google.com>2023-02-27 18:29:21 +0000
committerElliott Hughes <enh@google.com>2023-02-27 18:30:04 +0000
commit29532f4cc395acd9900fd1d26d082c65b43ec4d2 (patch)
tree04a0746f771c360f879e67d7d420641c85b9a182
parentcd3a47bf153d386dc4ad1a767b4e9ef1104566a6 (diff)
parentdf0eb047c7646acc01831c424f97d6673c08581c (diff)
downloadtoybox-29532f4cc395acd9900fd1d26d082c65b43ec4d2.tar.gz
Upgrade toybox to df0eb047c7646acc01831c424f97d6673c08581c
This project was upgraded with external_updater. Usage: tools/external_updater/updater.sh update toybox For more info, check https://cs.android.com/android/platform/superproject/+/master:tools/external_updater/README.md Test: TreeHugger Change-Id: Ia580e269db3319d13c8754d1d6ef6b5d423e6259
-rw-r--r--METADATA4
-rw-r--r--android/device/generated/help.h2
-rw-r--r--android/linux/generated/help.h2
-rw-r--r--android/mac/generated/help.h2
-rw-r--r--lib/lib.c5
-rwxr-xr-xtests/sed.test2
-rw-r--r--toys/pending/sh.c19
-rw-r--r--toys/pending/vi.c4
-rw-r--r--toys/posix/find.c28
-rw-r--r--toys/posix/ps.c6
-rw-r--r--toys/posix/sed.c8
11 files changed, 50 insertions, 32 deletions
diff --git a/METADATA b/METADATA
index 835605d2..c4e92e66 100644
--- a/METADATA
+++ b/METADATA
@@ -13,11 +13,11 @@ third_party {
type: GIT
value: "https://github.com/landley/toybox"
}
- version: "dbc6311ec7c9a0fe1c02a3acd8afb3be2ddb8e33"
+ version: "df0eb047c7646acc01831c424f97d6673c08581c"
license_type: UNENCUMBERED
last_upgrade_date {
year: 2023
month: 2
- day: 13
+ day: 27
}
}
diff --git a/android/device/generated/help.h b/android/device/generated/help.h
index 2f65d598..10d9383c 100644
--- a/android/device/generated/help.h
+++ b/android/device/generated/help.h
@@ -620,7 +620,7 @@
#define HELP_getconf "usage: getconf -a [PATH] | -l | NAME [PATH]\n\nGet system configuration values. Values from pathconf(3) require a path.\n\n-a Show all (defaults to \"/\" if no path given)\n-l List available value names (grouped by source)"
-#define HELP_find "usage: find [-HL] [DIR...] [<options>]\n\nSearch directories for matching files.\nDefault: search \".\", match all, -print matches.\n\n-H Follow command line symlinks -L Follow all symlinks\n\nMatch filters:\n-name PATTERN filename with wildcards -iname ignore case -name\n-path PATTERN path name with wildcards -ipath ignore case -path\n-user UNAME belongs to user UNAME -nouser user ID not known\n-group GROUP belongs to group GROUP -nogroup group ID not known\n-perm [-/]MODE permissions (-=min /=any) -prune ignore dir contents\n-size N[c] 512 byte blocks (c=bytes) -xdev only this filesystem\n-links N hardlink count -atime N[u] accessed N units ago\n-ctime N[u] created N units ago -mtime N[u] modified N units ago\n-inum N inode number N -empty empty files and dirs\n-true always true -false always false\n-context PATTERN security context -executable access(X_OK) perm+ACL\n-samefile FILE hardlink to FILE -quit exit immediately\n-depth contents first, then dir -maxdepth N at most N dirs down\n-newer FILE newer mtime than FILE -mindepth N at least N dirs down\n-newerXY FILE X=acm time > FILE's Y=acm time (Y=t: FILE is literal time)\n-type [bcdflps] type is (block, char, dir, file, symlink, pipe, socket)\n\nNumbers N may be prefixed by a - (less than) or + (greater than). Units for\n-Xtime are d (days, default), h (hours), m (minutes), or s (seconds).\n\nCombine matches with:\n!, -a, -o, ( ) not, and, or, group expressions\n\nActions:\n-print Print match with newline -print0 Print match with null\n-exec Run command with path -execdir Run command in file's dir\n-ok Ask before exec -okdir Ask before execdir\n-delete Remove matching file/dir -printf FORMAT Print using format string\n\nCommands substitute \"{}\" with matched file. End with \";\" to run each file,\nor \"+\" (next argument after \"{}\") to collect and run with multiple files.\n\n-printf FORMAT characters are \\ escapes and:\n%b 512 byte blocks used\n%f basename %g textual gid %G numeric gid\n%i decimal inode %l target of symlink %m octal mode\n%M ls format type/mode %p path to file %P path to file minus DIR\n%s size in bytes %T@ mod time as unixtime\n%u username %U numeric uid %Z security context"
+#define HELP_find "usage: find [-HL] [DIR...] [<options>]\n\nSearch directories for matching files.\nDefault: search \".\", match all, -print matches.\n\n-H Follow command line symlinks -L Follow all symlinks\n\nMatch filters:\n-name PATTERN filename with wildcards -iname ignore case -name\n-path PATTERN path name with wildcards -ipath ignore case -path\n-user UNAME belongs to user UNAME -nouser user ID not known\n-group GROUP belongs to group GROUP -nogroup group ID not known\n-perm [-/]MODE permissions (-=min /=any) -prune ignore dir contents\n-size N[c] 512 byte blocks (c=bytes) -xdev only this filesystem\n-links N hardlink count -empty empty files and dirs\n-atime N[u] accessed N units ago -true always true\n-ctime N[u] created N units ago -false always false\n-mtime N[u] modified N units ago -executable access(X_OK) perm+ACL\n-inum N inode number N -readable access(R_OK) perm+ACL\n-context PATTERN security context -depth contents before dir\n-samefile FILE hardlink to FILE -maxdepth N at most N dirs down\n-newer FILE newer mtime than FILE -mindepth N at least N dirs down\n-newerXY FILE X=acm time > FILE's Y=acm time (Y=t: FILE is literal time)\n-type [bcdflps] type is (block, char, dir, file, symlink, pipe, socket)\n\nNumbers N may be prefixed by - (less than) or + (greater than). Units for\n-[acm]time are d (days, default), h (hours), m (minutes), or s (seconds).\n\nCombine matches with:\n!, -a, -o, ( ) not, and, or, group expressions\n\nActions:\n-print Print match with newline -print0 Print match with null\n-exec Run command with path -execdir Run command in file's dir\n-ok Ask before exec -okdir Ask before execdir\n-delete Remove matching file/dir -printf FORMAT Print using format string\n-quit Exit immediately\n\nCommands substitute \"{}\" with matched file. End with \";\" to run each file,\nor \"+\" (next argument after \"{}\") to collect and run with multiple files.\n\n-printf FORMAT characters are \\ escapes and:\n%b 512 byte blocks used\n%f basename %g textual gid %G numeric gid\n%i decimal inode %l target of symlink %m octal mode\n%M ls format type/mode %p path to file %P path to file minus DIR\n%s size in bytes %T@ mod time as unixtime\n%u username %U numeric uid %Z security context"
#define HELP_file "usage: file [-bhLs] [FILE...]\n\nExamine the given files and describe their content types.\n\n-b Brief (no filename)\n-h Don't follow symlinks (default)\n-L Follow symlinks\n-s Show block/char device contents"
diff --git a/android/linux/generated/help.h b/android/linux/generated/help.h
index a4b4e634..b2b4485d 100644
--- a/android/linux/generated/help.h
+++ b/android/linux/generated/help.h
@@ -626,7 +626,7 @@
#define HELP_getconf "usage: getconf -a [PATH] | -l | NAME [PATH]\n\nGet system configuration values. Values from pathconf(3) require a path.\n\n-a Show all (defaults to \"/\" if no path given)\n-l List available value names (grouped by source)"
-#define HELP_find "usage: find [-HL] [DIR...] [<options>]\n\nSearch directories for matching files.\nDefault: search \".\", match all, -print matches.\n\n-H Follow command line symlinks -L Follow all symlinks\n\nMatch filters:\n-name PATTERN filename with wildcards -iname ignore case -name\n-path PATTERN path name with wildcards -ipath ignore case -path\n-user UNAME belongs to user UNAME -nouser user ID not known\n-group GROUP belongs to group GROUP -nogroup group ID not known\n-perm [-/]MODE permissions (-=min /=any) -prune ignore dir contents\n-size N[c] 512 byte blocks (c=bytes) -xdev only this filesystem\n-links N hardlink count -atime N[u] accessed N units ago\n-ctime N[u] created N units ago -mtime N[u] modified N units ago\n-inum N inode number N -empty empty files and dirs\n-true always true -false always false\n-context PATTERN security context -executable access(X_OK) perm+ACL\n-samefile FILE hardlink to FILE -quit exit immediately\n-depth contents first, then dir -maxdepth N at most N dirs down\n-newer FILE newer mtime than FILE -mindepth N at least N dirs down\n-newerXY FILE X=acm time > FILE's Y=acm time (Y=t: FILE is literal time)\n-type [bcdflps] type is (block, char, dir, file, symlink, pipe, socket)\n\nNumbers N may be prefixed by a - (less than) or + (greater than). Units for\n-Xtime are d (days, default), h (hours), m (minutes), or s (seconds).\n\nCombine matches with:\n!, -a, -o, ( ) not, and, or, group expressions\n\nActions:\n-print Print match with newline -print0 Print match with null\n-exec Run command with path -execdir Run command in file's dir\n-ok Ask before exec -okdir Ask before execdir\n-delete Remove matching file/dir -printf FORMAT Print using format string\n\nCommands substitute \"{}\" with matched file. End with \";\" to run each file,\nor \"+\" (next argument after \"{}\") to collect and run with multiple files.\n\n-printf FORMAT characters are \\ escapes and:\n%b 512 byte blocks used\n%f basename %g textual gid %G numeric gid\n%i decimal inode %l target of symlink %m octal mode\n%M ls format type/mode %p path to file %P path to file minus DIR\n%s size in bytes %T@ mod time as unixtime\n%u username %U numeric uid %Z security context"
+#define HELP_find "usage: find [-HL] [DIR...] [<options>]\n\nSearch directories for matching files.\nDefault: search \".\", match all, -print matches.\n\n-H Follow command line symlinks -L Follow all symlinks\n\nMatch filters:\n-name PATTERN filename with wildcards -iname ignore case -name\n-path PATTERN path name with wildcards -ipath ignore case -path\n-user UNAME belongs to user UNAME -nouser user ID not known\n-group GROUP belongs to group GROUP -nogroup group ID not known\n-perm [-/]MODE permissions (-=min /=any) -prune ignore dir contents\n-size N[c] 512 byte blocks (c=bytes) -xdev only this filesystem\n-links N hardlink count -empty empty files and dirs\n-atime N[u] accessed N units ago -true always true\n-ctime N[u] created N units ago -false always false\n-mtime N[u] modified N units ago -executable access(X_OK) perm+ACL\n-inum N inode number N -readable access(R_OK) perm+ACL\n-context PATTERN security context -depth contents before dir\n-samefile FILE hardlink to FILE -maxdepth N at most N dirs down\n-newer FILE newer mtime than FILE -mindepth N at least N dirs down\n-newerXY FILE X=acm time > FILE's Y=acm time (Y=t: FILE is literal time)\n-type [bcdflps] type is (block, char, dir, file, symlink, pipe, socket)\n\nNumbers N may be prefixed by - (less than) or + (greater than). Units for\n-[acm]time are d (days, default), h (hours), m (minutes), or s (seconds).\n\nCombine matches with:\n!, -a, -o, ( ) not, and, or, group expressions\n\nActions:\n-print Print match with newline -print0 Print match with null\n-exec Run command with path -execdir Run command in file's dir\n-ok Ask before exec -okdir Ask before execdir\n-delete Remove matching file/dir -printf FORMAT Print using format string\n-quit Exit immediately\n\nCommands substitute \"{}\" with matched file. End with \";\" to run each file,\nor \"+\" (next argument after \"{}\") to collect and run with multiple files.\n\n-printf FORMAT characters are \\ escapes and:\n%b 512 byte blocks used\n%f basename %g textual gid %G numeric gid\n%i decimal inode %l target of symlink %m octal mode\n%M ls format type/mode %p path to file %P path to file minus DIR\n%s size in bytes %T@ mod time as unixtime\n%u username %U numeric uid %Z security context"
#define HELP_file "usage: file [-bhLs] [FILE...]\n\nExamine the given files and describe their content types.\n\n-b Brief (no filename)\n-h Don't follow symlinks (default)\n-L Follow symlinks\n-s Show block/char device contents"
diff --git a/android/mac/generated/help.h b/android/mac/generated/help.h
index a4b4e634..b2b4485d 100644
--- a/android/mac/generated/help.h
+++ b/android/mac/generated/help.h
@@ -626,7 +626,7 @@
#define HELP_getconf "usage: getconf -a [PATH] | -l | NAME [PATH]\n\nGet system configuration values. Values from pathconf(3) require a path.\n\n-a Show all (defaults to \"/\" if no path given)\n-l List available value names (grouped by source)"
-#define HELP_find "usage: find [-HL] [DIR...] [<options>]\n\nSearch directories for matching files.\nDefault: search \".\", match all, -print matches.\n\n-H Follow command line symlinks -L Follow all symlinks\n\nMatch filters:\n-name PATTERN filename with wildcards -iname ignore case -name\n-path PATTERN path name with wildcards -ipath ignore case -path\n-user UNAME belongs to user UNAME -nouser user ID not known\n-group GROUP belongs to group GROUP -nogroup group ID not known\n-perm [-/]MODE permissions (-=min /=any) -prune ignore dir contents\n-size N[c] 512 byte blocks (c=bytes) -xdev only this filesystem\n-links N hardlink count -atime N[u] accessed N units ago\n-ctime N[u] created N units ago -mtime N[u] modified N units ago\n-inum N inode number N -empty empty files and dirs\n-true always true -false always false\n-context PATTERN security context -executable access(X_OK) perm+ACL\n-samefile FILE hardlink to FILE -quit exit immediately\n-depth contents first, then dir -maxdepth N at most N dirs down\n-newer FILE newer mtime than FILE -mindepth N at least N dirs down\n-newerXY FILE X=acm time > FILE's Y=acm time (Y=t: FILE is literal time)\n-type [bcdflps] type is (block, char, dir, file, symlink, pipe, socket)\n\nNumbers N may be prefixed by a - (less than) or + (greater than). Units for\n-Xtime are d (days, default), h (hours), m (minutes), or s (seconds).\n\nCombine matches with:\n!, -a, -o, ( ) not, and, or, group expressions\n\nActions:\n-print Print match with newline -print0 Print match with null\n-exec Run command with path -execdir Run command in file's dir\n-ok Ask before exec -okdir Ask before execdir\n-delete Remove matching file/dir -printf FORMAT Print using format string\n\nCommands substitute \"{}\" with matched file. End with \";\" to run each file,\nor \"+\" (next argument after \"{}\") to collect and run with multiple files.\n\n-printf FORMAT characters are \\ escapes and:\n%b 512 byte blocks used\n%f basename %g textual gid %G numeric gid\n%i decimal inode %l target of symlink %m octal mode\n%M ls format type/mode %p path to file %P path to file minus DIR\n%s size in bytes %T@ mod time as unixtime\n%u username %U numeric uid %Z security context"
+#define HELP_find "usage: find [-HL] [DIR...] [<options>]\n\nSearch directories for matching files.\nDefault: search \".\", match all, -print matches.\n\n-H Follow command line symlinks -L Follow all symlinks\n\nMatch filters:\n-name PATTERN filename with wildcards -iname ignore case -name\n-path PATTERN path name with wildcards -ipath ignore case -path\n-user UNAME belongs to user UNAME -nouser user ID not known\n-group GROUP belongs to group GROUP -nogroup group ID not known\n-perm [-/]MODE permissions (-=min /=any) -prune ignore dir contents\n-size N[c] 512 byte blocks (c=bytes) -xdev only this filesystem\n-links N hardlink count -empty empty files and dirs\n-atime N[u] accessed N units ago -true always true\n-ctime N[u] created N units ago -false always false\n-mtime N[u] modified N units ago -executable access(X_OK) perm+ACL\n-inum N inode number N -readable access(R_OK) perm+ACL\n-context PATTERN security context -depth contents before dir\n-samefile FILE hardlink to FILE -maxdepth N at most N dirs down\n-newer FILE newer mtime than FILE -mindepth N at least N dirs down\n-newerXY FILE X=acm time > FILE's Y=acm time (Y=t: FILE is literal time)\n-type [bcdflps] type is (block, char, dir, file, symlink, pipe, socket)\n\nNumbers N may be prefixed by - (less than) or + (greater than). Units for\n-[acm]time are d (days, default), h (hours), m (minutes), or s (seconds).\n\nCombine matches with:\n!, -a, -o, ( ) not, and, or, group expressions\n\nActions:\n-print Print match with newline -print0 Print match with null\n-exec Run command with path -execdir Run command in file's dir\n-ok Ask before exec -okdir Ask before execdir\n-delete Remove matching file/dir -printf FORMAT Print using format string\n-quit Exit immediately\n\nCommands substitute \"{}\" with matched file. End with \";\" to run each file,\nor \"+\" (next argument after \"{}\") to collect and run with multiple files.\n\n-printf FORMAT characters are \\ escapes and:\n%b 512 byte blocks used\n%f basename %g textual gid %G numeric gid\n%i decimal inode %l target of symlink %m octal mode\n%M ls format type/mode %p path to file %P path to file minus DIR\n%s size in bytes %T@ mod time as unixtime\n%u username %U numeric uid %Z security context"
#define HELP_file "usage: file [-bhLs] [FILE...]\n\nExamine the given files and describe their content types.\n\n-b Brief (no filename)\n-h Don't follow symlinks (default)\n-L Follow symlinks\n-s Show block/char device contents"
diff --git a/lib/lib.c b/lib/lib.c
index 9c5327d2..c9207a99 100644
--- a/lib/lib.c
+++ b/lib/lib.c
@@ -1559,6 +1559,11 @@ int smemcmp(char *one, char *two, unsigned long len)
{
int ii = 0;
+ // NULL sorts after anything else
+ if (one == two) return 0;
+ if (!one) return 1;
+ if (!two) return -1;
+
while (len--) if ((ii = *one++ - *two++)) break;
return ii;
diff --git a/tests/sed.test b/tests/sed.test
index fdd59404..59e80fa1 100755
--- a/tests/sed.test
+++ b/tests/sed.test
@@ -213,6 +213,8 @@ testing 's l loses missing newline' "sed -n 'N;l'" 'one\\ntwo$\n' '' 'one\ntwo'
testing 's -z l' "sed -zn 'N;l'" 'one\\000two$\0' '' 'one\0two\0'
testing 's -z l missing newline' "sed -zn 'N;l'" 'one\\000two$\0' '' 'one\0two'
+testcmd 'count match' '"s/./&X/4"' '0123X45\n' '' '012345\n'
+
# -i with $ last line test
#echo meep | sed/sed -e '1a\' -e 'huh'
diff --git a/toys/pending/sh.c b/toys/pending/sh.c
index 70989e68..2bdf64a3 100644
--- a/toys/pending/sh.c
+++ b/toys/pending/sh.c
@@ -2589,7 +2589,7 @@ static struct sh_process *expand_redir(struct sh_arg *arg, int skip, int *urd)
if (len != writeall(from, ss, len)) bad++;
if (ss != sss) free(ss);
} else {
- struct sh_arg *hh = arg+here++;
+ struct sh_arg *hh = arg+ ++here;
for (i = 0; i<hh->c; i++) {
ss = hh->v[i];
@@ -2961,7 +2961,7 @@ static int parse_line(char *line, struct sh_pipeline **ppl,
arg = pl->arg+1+pl->here;
// Match unquoted EOF.
- for (s = line, end = arg->v[arg->c]; *end; s++) {
+ for (s = line, end = arg->v[arg->c]; *end; s++, end++) {
s += strspn(s, "\\\"'");
if (!*s || *s != *end) break;
}
@@ -2997,11 +2997,16 @@ static int parse_line(char *line, struct sh_pipeline **ppl,
if (i+1 == arg->c) goto flush;
// Add another arg[] to the pipeline segment (removing/re-adding
- // to list because realloc can move pointer)
+ // to list because realloc can move pointer, and adjusing end pointers)
dlist_lpop(ppl);
+ pl2 = pl;
pl = xrealloc(pl, sizeof(*pl)+(++pl->count+1)*sizeof(struct sh_arg));
arg = pl->arg;
dlist_add_nomalloc((void *)ppl, (void *)pl);
+ for (pl3 = *ppl;;) {
+ if (pl3->end == pl2) pl3->end = pl;
+ if ((pl3 = pl3->next) == *ppl) break;
+ }
// queue up HERE EOF so input loop asks for more lines.
*(arg[pl->count].v = xzalloc(2*sizeof(void *))) = arg->v[++i];
@@ -3088,7 +3093,7 @@ static int parse_line(char *line, struct sh_pipeline **ppl,
}
// "for" on its own line is an error.
- if (arg->c == 1 && ex && !smemcmp(ex, "do\0A", 4)) {
+ if (arg->c == 1 && !smemcmp(ex, "do\0A", 4)) {
s = "newline";
goto flush;
}
@@ -3185,7 +3190,7 @@ static int parse_line(char *line, struct sh_pipeline **ppl,
free(s);
s = 0;
// TODO can't have ; between "for i" and in or do. (Newline yes, ; no. Why?)
- if (!arg->c && ex && !smemcmp(ex, "do\0C", 4)) continue;
+ if (!arg->c && !smemcmp(ex, "do\0C", 4)) continue;
// ;; and friends only allowed in case statements
} else if (*s == ';') goto flush;
@@ -3194,7 +3199,7 @@ static int parse_line(char *line, struct sh_pipeline **ppl,
continue;
// a for/select must have at least one additional argument on same line
- } else if (ex && !smemcmp(ex, "do\0A", 4)) {
+ } else if (!smemcmp(ex, "do\0A", 4)) {
// Sanity check and break the segment
if (strncmp(s, "((", 2) && *varend(s)) goto flush;
pl->count = -1;
@@ -3212,7 +3217,7 @@ static int parse_line(char *line, struct sh_pipeline **ppl,
// The "test" part of for/select loops can have (at most) one "in" line,
// for {((;;))|name [in...]} do
- if (ex && !smemcmp(ex, "do\0C", 4)) {
+ if (!smemcmp(ex, "do\0C", 4)) {
if (strcmp(s, "do")) {
// can only have one "in" line between for/do, but not with for(())
if (pl->prev->type == 's') goto flush;
diff --git a/toys/pending/vi.c b/toys/pending/vi.c
index e5a8e058..9e743dc3 100644
--- a/toys/pending/vi.c
+++ b/toys/pending/vi.c
@@ -1520,7 +1520,7 @@ static void draw_page()
void vi_main(void)
{
- char stdout_buf[BUFSIZ];
+ char stdout_buf[8192];
char keybuf[16] = {0};
char vi_buf[16] = {0};
char utf8_code[8] = {0};
@@ -1544,7 +1544,7 @@ void vi_main(void)
TT.screen_height -= 1;
// Avoid flicker.
- setbuf(stdout, stdout_buf);
+ setbuffer(stdout, stdout_buf, sizeof(stdout_buf));
xsignal(SIGWINCH, generic_signal);
set_terminal(0, 1, 0, 0);
diff --git a/toys/posix/find.c b/toys/posix/find.c
index 942d3ef4..f82817ca 100644
--- a/toys/posix/find.c
+++ b/toys/posix/find.c
@@ -29,19 +29,19 @@ config FIND
-group GROUP belongs to group GROUP -nogroup group ID not known
-perm [-/]MODE permissions (-=min /=any) -prune ignore dir contents
-size N[c] 512 byte blocks (c=bytes) -xdev only this filesystem
- -links N hardlink count -atime N[u] accessed N units ago
- -ctime N[u] created N units ago -mtime N[u] modified N units ago
- -inum N inode number N -empty empty files and dirs
- -true always true -false always false
- -context PATTERN security context -executable access(X_OK) perm+ACL
- -samefile FILE hardlink to FILE -quit exit immediately
- -depth contents first, then dir -maxdepth N at most N dirs down
- -newer FILE newer mtime than FILE -mindepth N at least N dirs down
- -newerXY FILE X=acm time > FILE's Y=acm time (Y=t: FILE is literal time)
+ -links N hardlink count -empty empty files and dirs
+ -atime N[u] accessed N units ago -true always true
+ -ctime N[u] created N units ago -false always false
+ -mtime N[u] modified N units ago -executable access(X_OK) perm+ACL
+ -inum N inode number N -readable access(R_OK) perm+ACL
+ -context PATTERN security context -depth contents before dir
+ -samefile FILE hardlink to FILE -maxdepth N at most N dirs down
+ -newer FILE newer mtime than FILE -mindepth N at least N dirs down
+ -newerXY FILE X=acm time > FILE's Y=acm time (Y=t: FILE is literal time)
-type [bcdflps] type is (block, char, dir, file, symlink, pipe, socket)
- Numbers N may be prefixed by a - (less than) or + (greater than). Units for
- -Xtime are d (days, default), h (hours), m (minutes), or s (seconds).
+ Numbers N may be prefixed by - (less than) or + (greater than). Units for
+ -[acm]time are d (days, default), h (hours), m (minutes), or s (seconds).
Combine matches with:
!, -a, -o, ( ) not, and, or, group expressions
@@ -51,6 +51,7 @@ config FIND
-exec Run command with path -execdir Run command in file's dir
-ok Ask before exec -okdir Ask before execdir
-delete Remove matching file/dir -printf FORMAT Print using format string
+ -quit Exit immediately
Commands substitute "{}" with matched file. End with ";" to run each file,
or "+" (next argument after "{}") to collect and run with multiple files.
@@ -352,8 +353,9 @@ static int do_find(struct dirtree *new)
if (check && bufgetgrgid(new->st.st_gid)) test = 0;
} else if (!strcmp(s, "prune")) {
if (check && S_ISDIR(new->st.st_mode) && !TT.depth) recurse = 0;
- } else if (!strcmp(s, "executable")) {
- if (check && faccessat(dirtree_parentfd(new), new->name,X_OK,0)) test = 0;
+ } else if (!strcmp(s, "executable") || !strcmp(s, "readable")) {
+ if (check && faccessat(dirtree_parentfd(new), new->name,
+ *s=='r' ? R_OK : X_OK, 0)) test = 0;
} else if (!strcmp(s, "quit")) {
if (check) {
execdir(0, 1);
diff --git a/toys/posix/ps.c b/toys/posix/ps.c
index 1fdfc17c..4f3807a8 100644
--- a/toys/posix/ps.c
+++ b/toys/posix/ps.c
@@ -1348,7 +1348,7 @@ void ps_main(void)
not_o = "F,S,UID,%sPPID,C,PRI,NI,BIT,SZ,WCHAN,TTY,TIME,CMD";
else if (CFG_TOYBOX_ON_ANDROID)
sprintf(not_o = toybuf+128,
- "USER,%%sPPID,VSIZE,RSS,WCHAN:10,ADDR:10,S,%s",
+ "USER,%%sPPID,VSIZE:10,RSS,WCHAN:10,ADDR:10,S,%s",
FLAG(T) ? "CMD" : "NAME");
sprintf(toybuf, not_o, FLAG(T) ? "PID,TID," : "PID,");
@@ -1521,13 +1521,13 @@ static void top_common(
"iow", "irq", "sirq", "host"};
unsigned tock = 0;
int i, lines, topoff = 0, done = 0;
- char stdout_buf[BUFSIZ];
+ char stdout_buf[8192];
if (!TT.fields) perror_exit("no -o");
// Avoid flicker and hide the cursor in interactive mode.
if (!FLAG(b)) {
- setbuf(stdout, stdout_buf);
+ setbuffer(stdout, stdout_buf, sizeof(stdout_buf));
sigatexit(top_cursor_cleanup);
xputsn("\e[?25l");
}
diff --git a/toys/posix/sed.c b/toys/posix/sed.c
index 44b3062a..d75b61a8 100644
--- a/toys/posix/sed.c
+++ b/toys/posix/sed.c
@@ -489,7 +489,7 @@ static void sed_line(char **pline, long plen)
// Zero length matches don't count immediately after a previous match
if (!mlen && !zmatch) {
if (rline-line == len) break;
- l2[l2used++] = *rline++;
+ if (l2) l2[l2used++] = *rline++;
zmatch++;
continue;
} else zmatch = 0;
@@ -524,7 +524,11 @@ static void sed_line(char **pline, long plen)
// Adjust allocation size of new string, copy data we know we'll keep
l2l += newlen-mlen;
- if ((l2l|0xfff) > l2old) l2 = xrealloc(l2, l2old = (l2l|0xfff)+1);
+ if ((mlen = l2l|0xfff) > l2old) {
+ l2 = xrealloc(l2, ++mlen);
+ if (l2used && !l2old) memcpy(l2, rline-l2used, l2used);
+ l2old = mlen;
+ }
if (match[0].rm_so) {
memcpy(l2+l2used, rline, match[0].rm_so);
l2used += match[0].rm_so;