delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2012/10/31/20:34:05

X-Recipient: archive-cygwin AT delorie DOT com
X-SWARE-Spam-Status: No, hits=-4.1 required=5.0 tests=BAYES_00,KHOP_THREADED,RP_MATCHES_RCVD
X-Spam-Check-By: sourceware.org
X-Server-Uuid: 4500596E-606A-40F9-852D-14843D8201B2
From: "Andrew Defaria" <adefaria AT broadcom DOT com>
To: "cygwin AT cygwin DOT com" <cygwin AT cygwin DOT com>
Subject: Re: Command line arguments
Date: Wed, 31 Oct 2012 20:29:11 +0000
Message-ID: <509189FA.8080302@DeFaria.com>
References: <1351606847888-94081 DOT post AT n5 DOT nabble DOT com> <20121031182143 DOT M67652 AT ds DOT net> <k6rtcp$fo8$1 AT ger DOT gmane DOT org> <20121031194051 DOT GL67410 AT justpickone DOT org>
In-Reply-To: <20121031194051.GL67410@justpickone.org>
MIME-Version: 1.0
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Id: <cygwin.cygwin.com>
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com
X-MIME-Autoconverted: from quoted-printable to 8bit by delorie.com id qA10Y1kQ027631

On 10/31/2012 12:40 PM, David T-G wrote:
> Andrew, et al --
>
> ...and then Andrew DeFaria said...
> %
> % On 10/31/2012 11:23 AM, Brian Wilson wrote:
> ...
> % >${1}, ${2}, etc.  Also, you may want to read up on the getopts command as a
> % >way to process command line arguments.
> % Technically, the {}'s are not needed. You can access them with $1, $2,
> ...
> % "/path/to/$1.save/dir" but not "/path/to/$1save/dir" you'd need the {}
> % (i.e. "/path/to/${1}save/dir" because otherwise the shell would be
> % looking for "1save" as an env variable name.
>
> ... except that environment variables cannot begin with numbers :-)
I was thinking that and should have tested it... Sorry if there was any 
confusion there.
>
>    davidtg AT madi:~ > cat /tmp/numvars.sh
>    bash --version
>    save=x
>    echo $save
>    1save=y
>    echo $1save
>    echo ${1save}
>    davidtg AT madi:~ > bash -x /tmp/numvars.sh
>    + bash --version
>    GNU bash, version 2.05a.0(1)-release (i386-portbld-freebsd4.6)
>    Copyright 2001 Free Software Foundation, Inc.
Interesting bash version there:

    $ bash --version
    GNU bash, version 4.1.10(4)-release (i686-pc-cygwin)
    Copyright (C) 2009 Free Software Foundation, Inc.
    License GPLv3+: GNU GPL version 3 or later
    <http://gnu.org/licenses/gpl.html>

    This is free software; you are free to change and redistribute it.
    There is NO WARRANTY, to the extent permitted by law.

You seem to be a bit behind...
>    + save=x
>    + echo x
>    x
>    + 1save=y
>    /tmp/numvars.sh: 1save=y: command not found
>    + echo save
>    save
>    /tmp/numvars.sh: ${1save}: bad substitution
>
>
> % --
> % Andrew DeFaria <http://defaria.com>
> % Fear has its use but cowardice has none. - Mohandas Gandhi
>
>
> HTH & Happy Hallowe'en
>
> :-D


-- 
Andrew DeFaria <http://defaria.com>
When everything's coming your way, you're in the wrong lane.

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple


- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019