X-Recipient: archive-cygwin@delorie.com
DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id
	:list-unsubscribe:list-subscribe:list-archive:list-post
	:list-help:sender:date:from:to:message-id:subject:mime-version
	:content-type:content-transfer-encoding; q=dns; s=default; b=jZN
	D1tK6MwshGO0uLBHzc2JJQpdld+8gSFLWbhcxPh/ifKfGSCiSjue8xz8wgbuVp9h
	A0uPp9ZQcFG9F9n053Kc8Rn8ec5AHYijo1R1X4uPvuLX9CMavu7fZIJ9W7ybfxhu
	aEh63CbKM1Uu8sYE+DQgKSrdns2HZ9G9d6irfA48=
DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id
	:list-unsubscribe:list-subscribe:list-archive:list-post
	:list-help:sender:date:from:to:message-id:subject:mime-version
	:content-type:content-transfer-encoding; s=default; bh=H5MreW1YW
	M2+TKDA0ifDqyrxsSs=; b=EnNCoUHIAc41uIj4GVqJkDTNNQjfozo6eT7C6lxqP
	nByEvEVm8OpSF6kb8XfmyaaljQzKSav3RStZZhjmkNdP9yjs+kODxZy2ybwZT5hr
	xtfeTIyn/7sAHN1jhX/kOMAyNhdSE8SnZTE085uDdSh3vI7AgaLmcCR209bHY1x9
	3s=
Mailing-List: contact cygwin-help@cygwin.com; run by ezmlm
List-Id: <cygwin.cygwin.com>
List-Subscribe: <mailto:cygwin-subscribe@cygwin.com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin@cygwin.com>
List-Help: <mailto:cygwin-help@cygwin.com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner@cygwin.com
Mail-Followup-To: cygwin@cygwin.com
Delivered-To: mailing list cygwin@cygwin.com
Authentication-Results: sourceware.org; auth=none
X-Virus-Found: No
X-Spam-SWARE-Status: No, score=-2.2 required=5.0 tests=AWL,BAYES_50,FREEMAIL_ENVFROM_END_DIGIT,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,RP_MATCHES_RCVD,SPF_PASS autolearn=ham version=3.3.2
X-HELO: sneak2.sneakemail.com
Date: Fri, 26 Jun 2015 21:27:07 +0000
From: ncokwqc02@sneakemail.com
To: cygwin@cygwin.com
Message-ID: <18831-1435354027-248572@sneakemail.com>
Subject: Re: Problem passing file names with embedded space to Windows executable via bash function
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 7bit

[ This is meant to be a reply to the response post by Ernie Rael, which I managed to lose so there is no referencing. ]

On 6/26/2015 12:50 PM, Ernie Rael wrote:

>I use something similar to this, perhaps it would meet your needs. You may want to use >different option to cygpath.
>
>   #!/usr/bin/bash
>
>   targs() {
>        if (($# == 0)); then
            _         _
>            args=()
>        else
>            IFS=$'\n'
                 _
>            args=($(cygpath -m -- "$@"))
                  ___           __     __
>            IFS=$' \t\n'
                 _
>        fi
>
>        for i in "${args[@]}"; do echo "'$i'"; done
>
>        some_command "${args[@]}"
                             ___
>   }
>
>
>-ernie

I modified Ernie's solution for my purposes and it works beautifully. Thanks so much.

The key point seems to be the temporary redefinition of IFS.

However, Ernie's solution also incorporates other features / syntactical elements of bash that I would never have thought to use and I'm interested to know if they are necessary and what they do. They are underlined in the message above. 

Basically,
1. Why the '(( .... ))' syntax with 'if'? Same as '[ .... ]'?
2. Why precede the white space characters with '$'?
3. Why enclose the 'cygpath' command by '($( ... ))'?
4. What does '--' do for 'cygpath'?
5. Why 'args[@]' rather than just 'args'?

Anyway, thanks for the simple solution to my problem. If I learn some more about obscure bash syntax that will be a bonus.

jjo


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

