delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2012/10/31/19:50:55

X-Recipient: archive-cygwin AT delorie DOT com
X-SWARE-Spam-Status: No, hits=-2.7 required=5.0 tests=AWL,BAYES_00,KHOP_THREADED,RP_MATCHES_RCVD
X-Spam-Check-By: sourceware.org
From: "Brian Wilson" <wilson AT ds DOT net>
To: cygwin AT cygwin DOT com
Subject: Re: Command line arguments
Date: Wed, 31 Oct 2012 13:23:58 -0500
Message-Id: <20121031182143.M67652@ds.net>
In-Reply-To: <1351606847888-94081.post@n5.nabble.com>
References: <1351606847888-94081 DOT post AT n5 DOT nabble DOT com>
X-OriginatingIP: 158.111.236.102 (wilson)
MIME-Version: 1.0
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

If you have a script (e.g. foo.sh) and you wish to pass arguments to the 
script, your command line should look like "foo.sh arg1 arg2 arg3..."  The 
number of arguments will be correct and you will be able to access them as 
${1}, ${2}, etc.  Also, you may want to read up on the getopts command as a 
way to process command line arguments.

Sincerely,

Brian S. Wilson
============================================================================

> In cygwin, is it possible to pass arguments to a shell script file? 
> I have installed the latest cygwin with default packages. I found 
> that argument zero ($0) is correct. However, the number of arguments 
> always returns zero
> ($#= 0) and $1, $2... are all null even though I did pass arguments.


--
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