Any Bash features you'd like to see?
Peter
plp-ysDPMY98cNQDDBjDh4tngg at public.gmane.org
Thu May 12 05:34:21 UTC 2005
On Wed, 11 May 2005, Chris F.A. Johnson wrote:
> X window commands, e.g.:
>
> window=$(openwindow -geometry 600x300+10+10)
> drawline $window 10 10 30 100
> text $window "Hello, world."
> closewindow $window
;-) There are a few command line programs that do that already (maybe
not at that level, you can't draw afaik). But why not go all the way and
bind several shells into a 'gshell' that would act as a wrapper and
transfer variables between the instances. Maybe it could handle
setting up pipes so programs can talk to each other while running
under it. Sample (totally fictitious):
#!/bin/gshell
#
# gshell stands for godzilla shell ;-)
#
WORKDIR=/some/where
# run commands under bash
# escape any curly braces in $*
SSTAR=`echo "$*"|sed -e 's/{/\{/g' -e 's/}/\}/g'`
!/bin/bash $SSTAR {
PWD=`pwd`
cd ${WORKDIR}
. ./config.cfg
# start something in the background, via bash
nohup mydaemon ${OPTS} $SSTAR &
PID=$!
}
# run a process under another instance of bash in the background -
# similar to what was done above, but different:
! $SSTAR {
cd ${WORKDIR}
# the '&' below puts the task in the background
!/bin/bash $* { &
. ./soft-daemon.sh ${OPTS} $SSTAR
}
PID=$!
LOST="something that will be lost"
export PID
}
# end context: undoes cd ${WORKDIR} and any shell variables set in the context
# and not exported are unset
# run commands under wish: gshell unescapes '\{' to '{' below etc
!/usr/bin/wish -- -foo "\{bar baz ${PID}\}" {
set pid [lindex [lindex $argv 3] 2]
wm title . {myapp: $pid}
label .l -text "Myapp (daemon PID=$pid)"
# etc etc
set logf [open $logfn {WRONLY APPEND CREAT}
# etc etc
puts $logf "$logstamp session end"
close $logf
}
# write a report using perl and mail errors somewhere if necessary
!/usr/bin/perl -W {
# perl code here
}
# exit with a code
exit 0
As you can see this is not very hard (famous last words) as each context
or instance can be implemented as a standalone shell script after very
simple text manipulation.
just fantasy (for now),
Peter
--
The Toronto Linux Users Group. Meetings: http://tlug.ss.org
TLUG requests: Linux topics, No HTML, wrap text below 80 columns
How to UNSUBSCRIBE: http://tlug.ss.org/subscribe.shtml
More information about the Legacy
mailing list