From: Philippe E. <ph...@wa...> - 2005-08-02 13:50:48
|
On Mon, 01 Aug 2005 at 22:47 +0000, Richard Purdie wrote: > As things stand there are several bash dependencies in the opcontrol > script. This means it can't run with the likes of busybox which is often > found in embedded systems instead of bash. > > This patch removes some of the simple problems: > http://projects.o-hand.com/oprofile/oprofile_nobash1.patch > > One further cleanup might be to set UID=`id -u` as the script starts and > then just access UID. > > With that applied, the only problem is the CHOSEN_EVENTS array. busybox > can't cope with arrays so this presents a problem. I can't see a way to > fix it just using shell variables. It is possible to use an events file > to get around this though: > > http://projects.o-hand.com/oprofile/oprofile_nobash2.patch > > Some simple functions are added to set and pull entries from the file, > the line number being used as the array index. > > I've tested this with both busybox and bash and it appears to work > although I'm not a regular user of the events syntax so there may be > something I've overlooked. > > I'm open to comments :) I've applied the first patch, perhaps the approach given by Ralf Wildenhues for the second patch is better : set_event() { eval "CHOSEN_EVENTS_$1=$2" } get_event() { eval "echo \$CHOSEN_EVENTS_$1" } set_event 2 foo:bar get_event 2 Is this enough portable ? regards, Philippe Elie |