mirror of
https://git.busybox.net/busybox.git
synced 2024-11-27 23:53:29 +08:00
So I'm building a linux from scratch system, using a working script to do this
that the _only_ change to is that gnu sed has been replaced with busybox sed. And ncurses' install phase hangs. I trace it down, and it's trying to run gawk. (Insert obligatory doubletake, but this is FSF code we're talking about, so...) It turns out gawk shells out to sed, ala "sed -f /tmp/blah file.h". The /tmp/blah file is basically empty (it contains one character, a newline). So basically, gawk is using sed as "cat". With gnu sed, it works like cat, anyway. With busybox sed, it tests if its command list is empty after parsing the command line, and if the list is empty it takes the first file argument as a sed command string, and if that leaves the file list empty it tries to read the data to operate on from stdin. (Hence the hang, since nothing's coming in on stdin...) It _should_ be testing whether there were any instances of -f or -e, not whether it actually got any commands. Using sed as cat may be kind of stupid, but it's valid and gawk relies on this behavior. Here's a patch to fix it, turning a couple of ints into chars in hopes of saving a bit of the space this adds. Comments? Rob
This commit is contained in:
parent
1219879422
commit
faa7d863fc
@ -1096,7 +1096,7 @@ static void add_cmd_block(char *cmdstr)
|
||||
|
||||
extern int sed_main(int argc, char **argv)
|
||||
{
|
||||
int opt, status = EXIT_SUCCESS;
|
||||
char opt, getpat=1, status = EXIT_SUCCESS;
|
||||
|
||||
#ifdef CONFIG_FEATURE_CLEAN_UP
|
||||
/* destroy command strings on exit */
|
||||
@ -1124,6 +1124,7 @@ extern int sed_main(int argc, char **argv)
|
||||
break;
|
||||
case 'e':
|
||||
add_cmd_block(optarg);
|
||||
getpat=0;
|
||||
break;
|
||||
case 'f':
|
||||
{
|
||||
@ -1135,6 +1136,7 @@ extern int sed_main(int argc, char **argv)
|
||||
while ((line = bb_get_chomped_line_from_file(cmdfile))
|
||||
!= NULL) {
|
||||
add_cmd(line);
|
||||
getpat=0;
|
||||
free(line);
|
||||
}
|
||||
bb_xprint_and_close_file(cmdfile);
|
||||
@ -1148,7 +1150,7 @@ extern int sed_main(int argc, char **argv)
|
||||
|
||||
/* if we didn't get a pattern from a -e and no command file was specified,
|
||||
* argv[optind] should be the pattern. no pattern, no worky */
|
||||
if (sed_cmd_head.next == NULL) {
|
||||
if(getpat) {
|
||||
if (argv[optind] == NULL)
|
||||
bb_show_usage();
|
||||
else
|
||||
|
Loading…
Reference in New Issue
Block a user