public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
From: Russell VT <russellvt@gmail.com>
To: Ev Drikos <drikosev@gmail.com>
Cc: cygwin <cygwin@cygwin.com>
Subject: Re: Incorrect expansion of a program argument that is a special character?
Date: Wed, 21 Jul 2021 05:18:56 -0700	[thread overview]
Message-ID: <CANV2+nWOVGzC=Nxmmc+xd43AH17XCQ2U2=8rC2uNKSjLT8V+nA@mail.gmail.com> (raw)
In-Reply-To: <CAK5_-8oS-CNCFqL6bqn3YgdnDF4ALq6tn3Z5_AzBEH-P3ai1yQ@mail.gmail.com>

Note that Powershell and BASH wildcard (globbing) may be notably different,
which includes how items may be "escaped" to prevent such globbing
operations.

Moreover, in a UN*X shell, it is generally thought that it's the user's
responsibility to declare how how file expansion should work, generally
defaulting to the "one or more" presence (where true regular expressions
use an asterisk as "zero or more"). In this way, shells and general regular
expressions may differ.

TLDR; In any environment, "arguments" are different between the command
line, and the program itself.

Basically, you need to understand how any given shell will pass arguments
to your program, and that exercise is generally outside of general
executable-type discussion (ie. it is almost a "religious war" as to how
various shells may process arguments, regular expressions, or wildcards ...
along with what options a user may specify to change the behaviour)

Do you have an example of where the program functions as-expected, along
with examples as to how the identical binary functions differently in
other environments?

Hope that lights a few lightbulbs for ya!

Russell VT


On Wed, Jul 21, 2021 at 4:44 AM Ev Drikos via Cygwin <cygwin@cygwin.com>
wrote:

> Hello,
>
> When I run the program below from my home directory in a PowerShell
> Console (Windows 8-1) I've to use an extra backslash character as
> shown below or the star is expanded. Which happens only when the
> program has been compiled in Cygwin.
>
> Is this a bug or a known feature?
>
> Ev. Drikos
>
> ----------------------------------------------
> PS C:\Users\suser> .\args.exe '\*'
>
> *
> argc=1
> PS C:\Users\suser>
> ----------------------------------------------
>
> #include <stdio.h>
> int main(int argc, char *argv[]){
> int i;
> for (i=1; i < argc; i++) {
>   printf("\n%s",argv[i]);
> }//for
>  printf("\nargc=%d\n",argc-1);
> return 0;
> }
>
> --
> Problem reports:      https://cygwin.com/problems.html
> FAQ:                  https://cygwin.com/faq/
> Documentation:        https://cygwin.com/docs.html
> Unsubscribe info:     https://cygwin.com/ml/#unsubscribe-simple
>


-- 
Russell M. Van Tassell <russellvt@gmail.com>

  reply	other threads:[~2021-07-21 12:19 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-07-21 11:42 Ev Drikos
2021-07-21 12:18 ` Russell VT [this message]
     [not found]   ` <CAK5_-8oOKuSQd35f2KF=q7Xy5mMQkukEUJa_dja+1WtHUGMcRQ@mail.gmail.com>
2021-07-21 14:21     ` Fwd: " Ev Drikos
2021-07-21 15:44 ` Brian Inglis

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CANV2+nWOVGzC=Nxmmc+xd43AH17XCQ2U2=8rC2uNKSjLT8V+nA@mail.gmail.com' \
    --to=russellvt@gmail.com \
    --cc=cygwin@cygwin.com \
    --cc=drikosev@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).