From owner-freebsd-questions Thu Mar 27 09:41:35 1997 Return-Path: Received: (from root@localhost) by freefall.freebsd.org (8.8.5/8.8.5) id JAA00403 for questions-outgoing; Thu, 27 Mar 1997 09:41:35 -0800 (PST) Received: from resnet.uoregon.edu (resnet.uoregon.edu [128.223.170.28]) by freefall.freebsd.org (8.8.5/8.8.5) with ESMTP id JAA00386 for ; Thu, 27 Mar 1997 09:41:11 -0800 (PST) Received: from localhost (dwhite@localhost) by resnet.uoregon.edu (8.8.3/8.6.12) with SMTP id JAA25878; Thu, 27 Mar 1997 09:41:02 -0800 (PST) Date: Thu, 27 Mar 1997 09:41:00 -0800 (PST) From: Doug White To: John Clark cc: questions@FreeBSD.ORG Subject: Re: BASH -> passing cmd line params In-Reply-To: <3.0.1.32.19970325173551.00aa5260@199.3.74.250> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-questions@FreeBSD.ORG X-Loop: FreeBSD.org Precedence: bulk On Tue, 25 Mar 1997, John Clark wrote: > Hello, I am having trouble passing a variable with a space in it as a > single parameter. Is there a way to do this? > > > #!/bin/sh > > PARAM1="hello world" > PARAM2="foo" > PARAM3="bar" > > mycommand $PARAM1 $PARAM2 $PARAM3 > > > The output of the above script shows 4 command line variables: 1=hello, > 2=world, 3=foo, 4=bar > > I would like: 1=hello world, 2=foo, 3=bar > > Any help would be appreciated. The output is correct. Remember that the space is the separator between options. If you want your program to consider "hello world" as one option, enclose itin quotations: mycommand "$PARAM1" $PARAM2 $PARAM3 Hope this helps. Doug White | University of Oregon Internet: dwhite@resnet.uoregon.edu | Residence Networking Assistant http://gladstone.uoregon.edu/~dwhite | Computer Science Major