mirror of
https://git.busybox.net/busybox
synced 2026-02-15 22:16:09 +00:00
Make the read built-in more compatible with bash: - Return an exit code of 142 on timeout. - When the timeout expires before a newline is detected in the input bash captures the partial input. This behaviour is new since bash version 4.4. BusyBox shells had the pre-4.4 behaviour where the input was lost. Update the tests to suit and fix a couple of compiler errors in the testsuite. function old new delta builtin_read 154 174 +20 readcmd 213 228 +15 shell_builtin_read 1364 1370 +6 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 3/0 up/down: 41/0) Total: 41 bytes Signed-off-by: Ron Yorston <rmy@pobox.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
58 lines
1.4 KiB
C
58 lines
1.4 KiB
C
/*
|
|
recho -- really echo args, bracketed with <> and with invisible chars
|
|
made visible.
|
|
|
|
Chet Ramey
|
|
chet@po.cwru.edu
|
|
*/
|
|
|
|
/* Copyright (C) 2002-2005 Free Software Foundation, Inc.
|
|
|
|
This file is part of GNU Bash, the Bourne Again SHell.
|
|
|
|
Bash is free software; you can redistribute it and/or modify it under
|
|
the terms of the GNU General Public License as published by the Free
|
|
Software Foundation; either version 2, or (at your option) any later
|
|
version.
|
|
|
|
Bash is distributed in the hope that it will be useful, but WITHOUT ANY
|
|
WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
for more details.
|
|
|
|
You should have received a copy of the GNU General Public License along
|
|
with Bash; see the file COPYING. If not, write to the Free Software
|
|
Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
|
|
|
|
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
|
|
void strprint(char *);
|
|
|
|
int main(int argc, char **argv)
|
|
{
|
|
int i;
|
|
|
|
for (i = 1; i < argc; i++) {
|
|
printf("argv[%d] = <", i);
|
|
strprint(argv[i]);
|
|
printf(">\n");
|
|
}
|
|
exit(EXIT_SUCCESS);
|
|
}
|
|
|
|
void strprint(char *str)
|
|
{
|
|
unsigned char *s;
|
|
|
|
for (s = (unsigned char *)str; s && *s; s++) {
|
|
if (*s < ' ') {
|
|
putchar('^');
|
|
putchar(*s+64);
|
|
} else if (*s == 127) {
|
|
putchar('^');
|
|
putchar('?');
|
|
} else
|
|
putchar(*s);
|
|
}
|
|
}
|