aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric Andersen <andersen@codepoet.org>2004-04-21 00:56:22 +0000
committerEric Andersen <andersen@codepoet.org>2004-04-21 00:56:22 +0000
commitfaa7d863fcdfe380a173cf7a005f481066bef703 (patch)
tree6e5d50cc8510396114dfbaf5a3a67eb54f79c222
parent1219879422fa33bf45d1eea0926483821e375bef (diff)
downloadbusybox-w32-faa7d863fcdfe380a173cf7a005f481066bef703.tar.gz
busybox-w32-faa7d863fcdfe380a173cf7a005f481066bef703.tar.bz2
busybox-w32-faa7d863fcdfe380a173cf7a005f481066bef703.zip
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
-rw-r--r--editors/sed.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/editors/sed.c b/editors/sed.c
index 4b1392551..968d0d2a2 100644
--- a/editors/sed.c
+++ b/editors/sed.c
@@ -1096,7 +1096,7 @@ static void add_cmd_block(char *cmdstr)
1096 1096
1097extern int sed_main(int argc, char **argv) 1097extern int sed_main(int argc, char **argv)
1098{ 1098{
1099 int opt, status = EXIT_SUCCESS; 1099 char opt, getpat=1, status = EXIT_SUCCESS;
1100 1100
1101#ifdef CONFIG_FEATURE_CLEAN_UP 1101#ifdef CONFIG_FEATURE_CLEAN_UP
1102 /* destroy command strings on exit */ 1102 /* destroy command strings on exit */
@@ -1124,6 +1124,7 @@ extern int sed_main(int argc, char **argv)
1124 break; 1124 break;
1125 case 'e': 1125 case 'e':
1126 add_cmd_block(optarg); 1126 add_cmd_block(optarg);
1127 getpat=0;
1127 break; 1128 break;
1128 case 'f': 1129 case 'f':
1129 { 1130 {
@@ -1135,6 +1136,7 @@ extern int sed_main(int argc, char **argv)
1135 while ((line = bb_get_chomped_line_from_file(cmdfile)) 1136 while ((line = bb_get_chomped_line_from_file(cmdfile))
1136 != NULL) { 1137 != NULL) {
1137 add_cmd(line); 1138 add_cmd(line);
1139 getpat=0;
1138 free(line); 1140 free(line);
1139 } 1141 }
1140 bb_xprint_and_close_file(cmdfile); 1142 bb_xprint_and_close_file(cmdfile);
@@ -1148,7 +1150,7 @@ extern int sed_main(int argc, char **argv)
1148 1150
1149 /* if we didn't get a pattern from a -e and no command file was specified, 1151 /* if we didn't get a pattern from a -e and no command file was specified,
1150 * argv[optind] should be the pattern. no pattern, no worky */ 1152 * argv[optind] should be the pattern. no pattern, no worky */
1151 if (sed_cmd_head.next == NULL) { 1153 if(getpat) {
1152 if (argv[optind] == NULL) 1154 if (argv[optind] == NULL)
1153 bb_show_usage(); 1155 bb_show_usage();
1154 else 1156 else