From owner-freebsd-questions@FreeBSD.ORG Fri Nov 26 18:44:59 2004 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 71C2F16A4CF for ; Fri, 26 Nov 2004 18:44:59 +0000 (GMT) Received: from lakermmtao06.cox.net (lakermmtao06.cox.net [68.230.240.33]) by mx1.FreeBSD.org (Postfix) with ESMTP id C334A43D5C for ; Fri, 26 Nov 2004 18:44:56 +0000 (GMT) (envelope-from conrads@cox.net) Received: from dolphin.local.net ([68.11.30.24]) by lakermmtao06.cox.net (InterMail vM.6.01.04.00 201-2131-117-20041022) with ESMTP <20041126184456.BBDV18218.lakermmtao06.cox.net@dolphin.local.net>; Fri, 26 Nov 2004 13:44:56 -0500 Received: from dolphin.local.net (localhost.local.net [127.0.0.1]) by dolphin.local.net (8.13.1/8.13.1) with SMTP id iAQIinsA071979; Fri, 26 Nov 2004 12:44:50 -0600 (CST) (envelope-from conrads@cox.net) Date: Fri, 26 Nov 2004 12:44:44 -0600 From: "Conrad J. Sabatier" To: Giorgos Keramidas 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> X-Mailer: Sylpheed-Claws 0.9.12b (GTK+ 1.2.10; amd64-portbld-freebsd6.0) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit cc: freebsd-questions@freebsd.org cc: Don Wilde Subject: Re: shell programming challenge X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 26 Nov 2004 18:44:59 -0000 On Fri, 26 Nov 2004 13:57:31 +0200, Giorgos Keramidas wrote: > On 2004-11-25 17:30, "Conrad J. Sabatier" 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 -- "In Unix veritas"