| www.delorie.com/archives/browse.cgi | search |
| X-Recipient: | archive-cygwin AT delorie DOT com |
| X-SWARE-Spam-Status: | No, hits=-3.2 required=5.0 tests=AWL,BAYES_00,KHOP_PGP_SIGNED |
| X-Spam-Check-By: | sourceware.org |
| Date: | Wed, 31 Oct 2012 15:40:51 -0400 |
| From: | David T-G <d12 AT justpickone DOT org> |
| To: | "CygWin Users' List" <cygwin AT cygwin DOT com> |
| Subject: | Re: Command line arguments |
| Message-ID: | <20121031194051.GL67410@justpickone.org> |
| 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> |
| Mime-Version: | 1.0 |
| In-Reply-To: | <k6rtcp$fo8$1@ger.gmane.org> |
| User-Agent: | Mutt/1.4i |
| X-IsSubscribed: | yes |
| Mailing-List: | contact cygwin-help AT cygwin DOT com; run by ezmlm |
| List-Id: | <cygwin.cygwin.com> |
| List-Unsubscribe: | <mailto:cygwin-unsubscribe-archive-cygwin=delorie DOT com AT cygwin DOT 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 |
--+TmfHRtzwn46KAcg
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable
Andrew, et al --
...and then Andrew DeFaria said...
%=20
% On 10/31/2012 11:23 AM, Brian Wilson wrote:
...
% >${1}, ${2}, etc. Also, you may want to read up on the getopts command a=
s a
% >way to process command line arguments.
% Technically, the {}'s are not needed. You can access them with $1, $2,=20
...
% "/path/to/$1.save/dir" but not "/path/to/$1save/dir" you'd need the {}=20
% (i.e. "/path/to/${1}save/dir" because otherwise the shell would be=20
% looking for "1save" as an env variable name.
... except that environment variables cannot begin with numbers :-)
davidtg AT madi:~ > cat /tmp/numvars.sh
bash --version
save=3Dx
echo $save
1save=3Dy
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.
+ save=3Dx
+ echo x
x
+ 1save=3Dy
/tmp/numvars.sh: 1save=3Dy: command not found
+ echo save
save
/tmp/numvars.sh: ${1save}: bad substitution
% --=20
% Andrew DeFaria <http://defaria.com>
% Fear has its use but cowardice has none. - Mohandas Gandhi
HTH & Happy Hallowe'en
:-D
--=20
David T-G
See http://justpickone.org/davidtg/email/
See http://justpickone.org/davidtg/tofu.txt
--+TmfHRtzwn46KAcg
Content-Type: application/pgp-signature
Content-Disposition: inline
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (FreeBSD)
iD8DBQFQkX7DGb7uCXufRwARApdFAKCoBbdSfEB+1xOnfXeoaSWFB+3RNwCgo3EV
VfAvOxPwsmSyb1glE2bjxmc=
=sMZj
-----END PGP SIGNATURE-----
--+TmfHRtzwn46KAcg--
| webmaster | delorie software privacy |
| Copyright © 2019 by DJ Delorie | Updated Jul 2019 |