possible bug with $@ and and non-standard IFS
Hi, In either version 3.1.17 (SUSE 10) or 3.2.25 (RHEL 5.3), with $DISPLAY set to :0.0 the following script gives unexpected results.(It works with version 3.0.15 - RHEL4.6) The echo should print out smith:0.0 instead of smith 0.0 #!!/bin/bash dh=smith oldIFS=$IFS IFS=: set $DISPLAY nd="${dh}:$@" IFS=$oldIFS echo $nd Thanks for taking a look at this. JR
omit fork before last exec
Hi, Would it be possible for bash to detect just-in-time the last subprocess that it will execute, and then do only an 'execve' instead of a fork+execve? This might save a lot of operating system overhead for process creation: perhaps upto 10% over the course of a day, especially for most uses of 'make'. It seems to me that this could work if there are no active traps and if the shell's input can be re-positioned without penalty. An active trap might get triggered by the supposed last subprocess; then interpreting the body of the trap could invalidate the "last subprocess" property. If the shell's input cannot be repositioned (is not a regular file or "-c" command line string; is a pipe, socket, fifo, character device, etc.) then lookahead on the shell's input is problematic. Lookahead is necessary to determine the "last subprocess" property. However, the lookahead must be undone before exec so that semantics remain the same for the case when the shell and a subprocess share the input stream. Piping input into a shell often relies on alternating consumption of the piped input by the shell and one or more subprocesses that have un-redirected stdin. Comments? --
Re: Need info on input keys
This may not serve my purpose. In my application there is a socket connection between 2 daemons. And say if client sends the message, the server receives the command the displays the output. If i give n messages/commands to client, the server will respond and in turn it has to remember the previous commands on up-arrow just like the bash shell. I want to implement key bindings and i want to enable the history option like bash shell in the client side. On Mon, Aug 3, 2009 at 6:57 AM, Mike Stroyan wrote: > On Tue, Jul 07, 2009 at 12:17:37PM +0530, seshikanth varma wrote: > > I need to implement history feature in an emulated shell environment. I > need > > to read keys present in the keyboard and define handler for each key. For > > example, Up arrow gives the previous command in the history. Can u please > > tell me how to make a start? > > Have a look at the readline library, which bash uses. > http://tiswww.case.edu/php/chet/readline/rltop.html > > -- > Mike Stroyan > -- Regards, Seshikanth
Re: Error with file descriptor
On Sat, Aug 01, 2009 at 07:36:36PM +0200, Aljosha Papsch wrote: > ModManager() { > ClearFiles -4 > echo "zenity --list --window-icon=\"${run_path}icon.png\" > --width=\"650\" --height=\"350\" --title=\"${modmanager[${lang}]}\" > --text=\"${RegMods[${lang}]}:\" --column=\"${no[${lang}]}\" > --column=\"${name_loc[${lang}]}\" --column=\"Modus\" \\" >&4 > for (( a = 1; a <= MODULES; a++ )) > do >echo "${a} \"${mod[${a}]} in ${loc[${a}]}\" ${mode[${a}]} \\" >&4 > done > echo "__ ___ __ \\" >&4 > echo "add \"${add_mod[${lang}]}\" __ \\" >&4 > echo "del \"${del_mod[${lang}]}\" __ \\" >&4 > echo "back \"${back[${lang}]}\" __" >&4 > command=`. ${tmpmenu}` I presume FD 4 is pointing to the file named in ${tmpmenu}. You should probably close FD 4 before attempting to read from the file, to be sure all buffers are flushed. Another way to build up a command for later execution would be to use an array instead of a file: zcmd=(zenity --list --window-icon="${run_path}icon.png" ...) for (( some loop )); do zcmd+=($a "some thing" "etc.") done "${zc...@]}"