X-Recipient: archive-cygwin AT delorie DOT com X-SWARE-Spam-Status: No, hits=-3.5 required=5.0 tests=AWL,BAYES_00,KHOP_THREADED,RP_MATCHES_RCVD,SPF_HELO_PASS X-Spam-Check-By: sourceware.org To: cygwin AT cygwin DOT com From: Andrew DeFaria Subject: Re: Command line arguments Date: Wed, 31 Oct 2012 13:28:42 -0700 Lines: 65 Message-ID: <509189FA.8080302@DeFaria.com> References: <1351606847888-94081 DOT post AT n5 DOT nabble DOT com> <20121031182143 DOT M67652 AT ds DOT net> <20121031194051 DOT GL67410 AT justpickone DOT org> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit User-Agent: Mozilla/5.0 (Windows NT 6.1; rv:16.0) Gecko/20121010 Thunderbird/16.0.1 In-Reply-To: <20121031194051.GL67410@justpickone.org> X-IsSubscribed: yes Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com Delivered-To: mailing list cygwin AT cygwin DOT com 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 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 > % Fear has its use but cowardice has none. - Mohandas Gandhi > > > HTH & Happy Hallowe'en > > :-D -- Andrew DeFaria 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