Date: Fri, 26 Nov 2004 12:44:44 -0600 From: "Conrad J. Sabatier" <conrads@cox.net> To: Giorgos Keramidas <keramida@ceid.upatras.gr> Cc: Don Wilde <Don@Silver-Lynx.com> Subject: Re: shell programming challenge Message-ID: <20041126124444.007749e8@dolphin.local.net> In-Reply-To: <20041126115731.GB1768@orion.daedalusnetworks.priv> References: <41A615CE.6010405@Silver-Lynx.com> <1101405587.63632.10.camel@dolphin.local.net> <20041125173018.0444d52c@dolphin.local.net> <20041126115731.GB1768@orion.daedalusnetworks.priv>
next in thread | previous in thread | raw e-mail | index | archive | help
On Fri, 26 Nov 2004 13:57:31 +0200, Giorgos Keramidas
<keramida@ceid.upatras.gr> wrote:
> On 2004-11-25 17:30, "Conrad J. Sabatier" <conrads@cox.net> wrote:
> >
> > OK, I think I've found what you're looking for:
> >
> > xterm -e "/usr/local/bin/bash --rcfile bash_commands -i"
> >
> > Substitute your program's startup script for "bash_commands" in the
> > above. Using the "-i" switch to bash forces interactive mode, so
> > when the script exits, you'll be returned to the shell prompt in the
> > xterm. As it turns out, xterm's "-hold" switch is wholly unnecessary
> > here.
> >
> > Note that the "--rcfile" switch, being a "double-hyphened" option,
> > must precede the later "-i" switch in order to be recognized.
>
> Cool trick!
Thanks. :-)
> I was thinking something like adding the following to the local
> .bashrc:
>
> [-- .bashrc --]
>
> if [ ! X"${BASHRC_LOCAL}" = X"" ] && \
> [ -r "${BASHRC_LOCAL}" ]; then
> . "${BASHRC_LOCAL}"
> fi
>
> Then running xterm with BASHRC_LOCAL set to the path of the local bash
> script:
>
> BASHRC_LOCAL="/path/foo" xterm -e bash
>
> --rcfile is better though :-)
Yes, it's much simpler, for sure. :-)
By the way, there are some better testing constructs that eliminate
the need for using the old sh trick of "X$SOMEVAR" to avoid syntax
errors. The above expression could be written as:
if [ -n ${BASHRC_LOCAL} -a -r ${BASHRC_LOCAL} ]; then ...
Or using opposite logic:
if [ ! -z ${BASHRC_LOCAL} ...
Unix shells are just so damn cool, aren't they? :-)
--
Conrad J. Sabatier <conrads@cox.net> -- "In Unix veritas"
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20041126124444.007749e8>
