int nchars; /* -n NUM */
char **pp;
char *buffer;
+ char delim;
struct termios tty, old_tty;
const char *retval;
int bufpos; /* need to be able to hold -1 */
end_ms += (unsigned)monotonic_ms();
buffer = NULL;
bufpos = 0;
+ delim = opt_d ? *opt_d : '\n';
do {
char c;
int timeout;
continue;
}
}
- if (opt_d) {
- if (c == *opt_d)
- break;
- } else if (c == '\n')
+ if (c == delim) /* '\n' or -d CHAR */
break;
/* $IFS splitting. NOT done if we run "read"
BUILTIN_READ_SILENT = 1 << 0,
BUILTIN_READ_RAW = 1 << 1,
};
+//TODO? do not provide bashisms if not asked for:
+//#if !ENABLE_HUSH_BASH_COMPAT && !ENABLE_ASH_BASH_COMPAT
+//#define shell_builtin_read(setvar,argv,ifs,read_flags,n,p,t,u,d)
+// shell_builtin_read(setvar,argv,ifs,read_flags)
+//#endif
const char* FAST_FUNC
shell_builtin_read(void FAST_FUNC (*setvar)(const char *name, const char *val),
char **argv,