From: Masatake Y. <ya...@re...> - 2008-08-04 11:34:38
|
Hi, (I lost je...@gy.... Please use ya...@re... to contact with me about FOSS.) I have a chance to read set0. I have not had time to build it. However, I could find some lines which will cause troubles. Could you review following patch? 2008-08-04 Masatake YAMATO <ya...@re...> * builtin/set0.c: Fix comments. (set0_builtin): Free $0 before overwriting. Return SUCCESS instead of FAILURE. Index: set0.c =================================================================== RCS file: /cvsroot/bashdb/bash-3.1/builtin/set0.c,v retrieving revision 1.1 diff -c -r1.1 set0.c *** set0.c 23 May 2008 23:55:25 -0000 1.1 --- set0.c 4 Aug 2008 11:30:01 -0000 *************** *** 1,5 **** /* ! Extends bash with a builtin function to test if a name is defined or not. To install after compiling: cd *this directory* --- 1,5 ---- /* ! Set $0. To install after compiling: cd *this directory* *************** *** 31,38 **** return (EX_USAGE); } dollar_vars[0] = savestring(list->word->word); ! return EXECUTION_FAILURE; } struct builtin set0_struct = { --- 31,41 ---- return (EX_USAGE); } + if (dollar_vars[0]) + free (dollar_vars[0]); + dollar_vars[0] = savestring(list->word->word); ! return EXECUTION_SUCCESS; } struct builtin set0_struct = { |
From: Rocky B. <roc...@gm...> - 2008-08-04 12:14:30
|
Thanks. It is great to have someone else looking over the code. As usual, you are correct. I've also updated the unit test in test/unit/test-set0.sh.in so it would have caught at least one of the flaws. On Mon, Aug 4, 2008 at 7:34 AM, Masatake YAMATO <ya...@re...> wrote: > Hi, > > (I lost je...@gy.... > Please use ya...@re... to contact with me about FOSS.) > > I have a chance to read set0. > I have not had time to build it. However, I could find some lines > which will cause troubles. Could you review following patch? > > > 2008-08-04 Masatake YAMATO <ya...@re...> > > * builtin/set0.c: Fix comments. > (set0_builtin): Free $0 before overwriting. > Return SUCCESS instead of FAILURE. > > Index: set0.c > =================================================================== > RCS file: /cvsroot/bashdb/bash-3.1/builtin/set0.c,v > retrieving revision 1.1 > diff -c -r1.1 set0.c > *** set0.c 23 May 2008 23:55:25 -0000 1.1 > --- set0.c 4 Aug 2008 11:30:01 -0000 > *************** > *** 1,5 **** > /* > ! Extends bash with a builtin function to test if a name is defined or not. > > To install after compiling: > cd *this directory* > --- 1,5 ---- > /* > ! Set $0. > > To install after compiling: > cd *this directory* > *************** > *** 31,38 **** > return (EX_USAGE); > } > > dollar_vars[0] = savestring(list->word->word); > ! return EXECUTION_FAILURE; > } > > struct builtin set0_struct = { > --- 31,41 ---- > return (EX_USAGE); > } > > + if (dollar_vars[0]) > + free (dollar_vars[0]); > + > dollar_vars[0] = savestring(list->word->word); > ! return EXECUTION_SUCCESS; > } > > struct builtin set0_struct = { > > ------------------------------------------------------------------------- > This SF.Net email is sponsored by the Moblin Your Move Developer's challenge > Build the coolest Linux based applications with Moblin SDK & win great prizes > Grand prize is a trip for two to an Open Source event anywhere in the world > http://moblin-contest.org/redirect.php?banner_id=100&url=/ > _______________________________________________ > Bashdb-devel mailing list > Bas...@li... > https://lists.sourceforge.net/lists/listinfo/bashdb-devel > |
From: Rocky B. <roc...@gm...> - 2008-08-05 11:41:21
|
Copyright added. Sure, getting into bash is probably a good thing to do. I thought somewhere I saw a builtin function called something like SETVAR0 for zsh which does the same thing. I don't see it now though. But the idea is that if there are other corresponding builtin functions for other shells, I'd like to try to call this the same thing and have it work the same way. Which reminds me about readarray. zsh does have a builtin function called mapfile. However that doesn't work like readarray. Instead it reads a file in as a string preserving and newlines are inside the string. You'd still have to split the string into an array. The purpose of set0 in the debugger is that users often write programs that refer to $0. For example to display a usage string or maybe they change the behavior based on how they were called. So this helps in making these programs act the same way and gives an alternative to invoking with "bash --debugger". On Tue, Aug 5, 2008 at 1:11 AM, Masatake YAMATO <ya...@re...> wrote: >> As usual, you are correct. I've also updated the unit test in >> test/unit/test-set0.sh.in so it would have caught at least one of the >> flaws. > > Should I push set0 to Chet Ramey? > If yes please put copyright notice to set0.c. > > Masatake YAMATO > |
From: Masatake Y. <ya...@re...> - 2008-08-05 05:11:44
|
> As usual, you are correct. I've also updated the unit test in > test/unit/test-set0.sh.in so it would have caught at least one of the > flaws. Should I push set0 to Chet Ramey? If yes please put copyright notice to set0.c. Masatake YAMATO |
From: Masatake Y. <ya...@re...> - 2008-08-13 10:25:16
|
> Copyright added. Sure, getting into bash is probably a good thing to > do. I thought somewhere I saw a builtin function called something like > SETVAR0 for zsh which does the same thing. I don't see it now though. > But the idea is that if there are other corresponding builtin > functions for other shells, I'd like to try to call this the same > thing and have it work the same way. > > Which reminds me about readarray. zsh does have a builtin function > called mapfile. However that doesn't work like readarray. Instead it > reads a file in as a string preserving and newlines are inside the > string. You'd still have to split the string into an array. > > The purpose of set0 in the debugger is that users often write programs > that refer to $0. For example to display a usage string or maybe they > change the behavior based on how they were called. So this helps in > making these programs act the same way and gives an alternative to > invoking with "bash --debugger". Thank you for the explanation. I think set0 is very good name. The name tell its function well. So I'll push set0 to the bash maintainer. However, I think extending the original `set' command to handle $0 is not so bad. So I'll propose both the name set0 and extending set to the maintainer, and I'll get the comment from him. Masatake YAMATO |
From: Rocky B. <roc...@gm...> - 2008-08-25 14:12:51
|
Thanks! Should be applied now. Also removed this target in the parent Makefile which a holdover from the time when we were building builtins there. I had to apply the patch by hand since cut-and pasting into a patch file didn't work. So please double check. On Mon, Aug 25, 2008 at 8:29 AM, Masatake YAMATO <ya...@re...> wrote: > Hi, > > The argument for rm in set0$(EXEEXT) target of builtin/Makefile > is wrong. Here is a patch for fixing it. > > 2008-08-25 Masatake YAMATO <ya...@re...> > > * builtin/Makefile.am: Give $@ to rm. > > Index: Makefile.am > =================================================================== > RCS file: /cvsroot/bashdb/bash-3.1/builtin/Makefile.am,v > retrieving revision 1.4 > diff -c -r1.4 Makefile.am > *** Makefile.am 13 Jul 2008 21:20:30 -0000 1.4 > --- Makefile.am 25 Aug 2008 12:26:57 -0000 > *************** > *** 9,15 **** > readarray_LDFLAGS = -shared > > readarray$(EXEEXT): $(readarray_OBJECTS) $(readarray_DEPENDENCIES) > ! @rm -f readarray$(EXEEXT) > $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@ \ > $(readarray_LDFLAGS) $(readarray_OBJECTS) $(readarray_LDADD) $(LIBS) > > --- 9,15 ---- > readarray_LDFLAGS = -shared > > readarray$(EXEEXT): $(readarray_OBJECTS) $(readarray_DEPENDENCIES) > ! @rm -f $@ > $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@ \ > $(readarray_LDFLAGS) $(readarray_OBJECTS) $(readarray_LDADD) $(LIBS) > > *************** > *** 19,25 **** > set0_builtin = set0 > > set0$(EXEEXT): $(set0_OBJECTS) $(set0_DEPENDENCIES) > ! @rm -f readarray$(EXEEXT) > $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@ \ > $(set0_LDFLAGS) $(set0_OBJECTS) $(set0_LDADD) $(LIBS) > > --- 19,25 ---- > set0_builtin = set0 > > set0$(EXEEXT): $(set0_OBJECTS) $(set0_DEPENDENCIES) > ! @rm -f $@ > $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@ \ > $(set0_LDFLAGS) $(set0_OBJECTS) $(set0_LDADD) $(LIBS) > > > ------------------------------------------------------------------------- > This SF.Net email is sponsored by the Moblin Your Move Developer's challenge > Build the coolest Linux based applications with Moblin SDK & win great prizes > Grand prize is a trip for two to an Open Source event anywhere in the world > http://moblin-contest.org/redirect.php?banner_id=100&url=/ > _______________________________________________ > Bashdb-devel mailing list > Bas...@li... > https://lists.sourceforge.net/lists/listinfo/bashdb-devel > |
From: Masatake Y. <ya...@re...> - 2008-08-26 02:36:29
|
> Thanks! Should be applied now. Also removed this target in the parent > Makefile which a holdover from the time when we were building builtins > there. > > I had to apply the patch by hand since cut-and pasting into a patch > file didn't work. So please double check. I checed. The patch was applied well. Thank you. Masatake YAMATO |
From: Masatake Y. <ya...@re...> - 2008-08-25 12:29:47
|
Hi, The argument for rm in set0$(EXEEXT) target of builtin/Makefile is wrong. Here is a patch for fixing it. 2008-08-25 Masatake YAMATO <ya...@re...> * builtin/Makefile.am: Give $@ to rm. Index: Makefile.am =================================================================== RCS file: /cvsroot/bashdb/bash-3.1/builtin/Makefile.am,v retrieving revision 1.4 diff -c -r1.4 Makefile.am *** Makefile.am 13 Jul 2008 21:20:30 -0000 1.4 --- Makefile.am 25 Aug 2008 12:26:57 -0000 *************** *** 9,15 **** readarray_LDFLAGS = -shared readarray$(EXEEXT): $(readarray_OBJECTS) $(readarray_DEPENDENCIES) ! @rm -f readarray$(EXEEXT) $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@ \ $(readarray_LDFLAGS) $(readarray_OBJECTS) $(readarray_LDADD) $(LIBS) --- 9,15 ---- readarray_LDFLAGS = -shared readarray$(EXEEXT): $(readarray_OBJECTS) $(readarray_DEPENDENCIES) ! @rm -f $@ $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@ \ $(readarray_LDFLAGS) $(readarray_OBJECTS) $(readarray_LDADD) $(LIBS) *************** *** 19,25 **** set0_builtin = set0 set0$(EXEEXT): $(set0_OBJECTS) $(set0_DEPENDENCIES) ! @rm -f readarray$(EXEEXT) $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@ \ $(set0_LDFLAGS) $(set0_OBJECTS) $(set0_LDADD) $(LIBS) --- 19,25 ---- set0_builtin = set0 set0$(EXEEXT): $(set0_OBJECTS) $(set0_DEPENDENCIES) ! @rm -f $@ $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@ \ $(set0_LDFLAGS) $(set0_OBJECTS) $(set0_LDADD) $(LIBS) |