Recallcitrant wildcards

Discussion in 'Java' started by Roedy Green, Apr 8, 2009.

  1. Roedy Green

    Roedy Green Guest

    I have discovered that if you put something like

    cert*.html
    on the command line it gets expanded to:
    certificate.html certificatevendors.html certification.html

    I discovered when you pass this wildcard to a DOS *.com program the
    expansion does not happen.

    I discovered when you pass this wildcard to a C *.exe program, the
    expansion does not happen.

    This suggests Java, not the command processor is doing the expansion.


    I want to turn this expansion off.

    So I tried passing

    "cert*.html"

    No joy. same thing.

    I then tried

    "cert\*.html"

    and I was able to suppress the expansion, but internally I got
    "cert\.html"

    Is there some way to get my data passed through unmolested?


    --
    Roedy Green Canadian Mind Products
    http://mindprod.com

    "At this point, 29 percent of fish and seafood species have collapsed - that is,
    their catch has declined by 90 percent. It is a very clear trend, and it is accelerating.
    If the long-term trend continues, all fish and seafood species are projected to collapse
    within my lifetime -- by 2048."
    ~ Dr. Boris Worm of Dalhousie University
    Roedy Green, Apr 8, 2009
    #1
    1. Advertising

  2. Roedy Green

    Mark Space Guest

    Roedy Green wrote:

    >
    > Is there some way to get my data passed through unmolested?



    SSCCE?


    ;)
    Mark Space, Apr 8, 2009
    #2
    1. Advertising

  3. Roedy Green wrote:
    > I have discovered that if you put something like
    >
    > cert*.html
    > on the command line it gets expanded to:
    > certificate.html certificatevendors.html certification.html
    >
    > I discovered when you pass this wildcard to a DOS *.com program the
    > expansion does not happen.
    >
    > I discovered when you pass this wildcard to a C *.exe program, the
    > expansion does not happen.
    >
    > This suggests Java, not the command processor is doing the expansion.
    >
    >
    > I want to turn this expansion off.
    >
    > So I tried passing
    >
    > "cert*.html"
    >
    > No joy. same thing.
    >
    > I then tried
    >
    > "cert\*.html"
    >
    > and I was able to suppress the expansion, but internally I got
    > "cert\.html"
    >
    > Is there some way to get my data passed through unmolested?
    >


    Odd. With this test code

    public class StarTest {

    public static void main(String[] args) {
    for (String arg : args) {
    System.out.println(arg);
    }
    }
    }

    the command line

    java StarTest "s*.java"

    printed

    s*.java

    not all my Java files starting with s
    Chris Riesbeck, Apr 8, 2009
    #3
  4. Roedy Green

    Mark Space Guest

    Chris Riesbeck wrote:
    > Roedy Green wrote:
    >> I have discovered that if you put something like
    >>
    >> cert*.html
    >> on the command line it gets expanded to:
    >> certificate.html certificatevendors.html certification.html
    >>
    >> I discovered when you pass this wildcard to a DOS *.com program the
    >> expansion does not happen.
    >> I discovered when you pass this wildcard to a C *.exe program, the
    >> expansion does not happen.
    >>
    >> This suggests Java, not the command processor is doing the expansion.
    >>
    >>
    >> I want to turn this expansion off.
    >>
    >> So I tried passing
    >>
    >> "cert*.html"
    >>
    >> No joy. same thing.
    >>
    >> I then tried
    >>
    >> "cert\*.html"
    >>
    >> and I was able to suppress the expansion, but internally I got
    >> "cert\.html"
    >>
    >> Is there some way to get my data passed through unmolested?
    >>

    >
    > Odd. With this test code
    >
    > public class StarTest {
    >
    > public static void main(String[] args) {
    > for (String arg : args) {
    > System.out.println(arg);
    > }
    > }
    > }
    >
    > the command line
    >
    > java StarTest "s*.java"
    >
    > printed
    >
    > s*.java
    >
    > not all my Java files starting with s
    >



    Which shell are you using?
    Mark Space, Apr 8, 2009
    #4
  5. Roedy Green

    Roedy Green Guest

    On Wed, 08 Apr 2009 09:58:16 -0700, Mark Space
    <> wrote, quoted or indirectly quoted someone
    who said :

    >> Is there some way to get my data passed through unmolested?

    >
    >
    >SSCCE?

    see http://mindprod.com/jgloss/wildcard.html
    --
    Roedy Green Canadian Mind Products
    http://mindprod.com

    "At this point, 29 percent of fish and seafood species have collapsed - that is,
    their catch has declined by 90 percent. It is a very clear trend, and it is accelerating.
    If the long-term trend continues, all fish and seafood species are projected to collapse
    within my lifetime -- by 2048."
    ~ Dr. Boris Worm of Dalhousie University
    Roedy Green, Apr 8, 2009
    #5
  6. Roedy Green

    Roedy Green Guest

    Re: Recalcitrant wildcards

    On Wed, 08 Apr 2009 10:46:44 -0700, Mark Space
    <> wrote, quoted or indirectly quoted someone
    who said :

    >Which shell are you using?


    Take command. I was doing my experiments in IntelliJ. I don't know
    what it does for a shell.

    I guess my first job is to figure out who is doing the expansion. I
    figured I had proof giving it was not happening with a COM asm or C
    exe command line.

    Perhaps java does the expansion if it can find files that match, but
    does not otherwise.

    More experiments are in order.
    --
    Roedy Green Canadian Mind Products
    http://mindprod.com

    "At this point, 29 percent of fish and seafood species have collapsed - that is,
    their catch has declined by 90 percent. It is a very clear trend, and it is accelerating.
    If the long-term trend continues, all fish and seafood species are projected to collapse
    within my lifetime -- by 2048."
    ~ Dr. Boris Worm of Dalhousie University
    Roedy Green, Apr 8, 2009
    #6
  7. Roedy Green

    Lew Guest

    Chris Riesbeck wrote:
    >> Odd. With this test code
    >> ...
    >> the command line
    >>
    >>    java StarTest "s*.java"
    >>
    >> printed
    >>
    >>    s*.java
    >>
    >> not all my Java files starting with s

    >


    Mark Space wrote:
    > Which shell are you using?
    >


    With 'bash' and similar shells, the expansion of "s*.java" depends on
    the presence of such files in the current working directory (cwd). If
    no files match the pattern, the string is passed unchanged to the
    invoked program, as Chris Riesbeck observed. If files in the cwd do
    match the pattern, the string is expanded to the list of such files,
    and the list is passed to the program (as a single parameter since it
    was quoted).

    Were the parameter encased in single quotes, 's*.java', no expansion
    would occur regardless of whether any files in the cwd match the
    pattern.

    Were it not encased in any quotes, s*.java would expand to the list of
    any matching file names, assuming there are any, one parameter per
    name.

    See the EXPANSION section in
    <http://www.cs.sunysb.edu/documentation/bash/bash.html>

    As to Roedy's question, encase the parameter in single quotes.

    --
    Lew
    Lew, Apr 8, 2009
    #7
  8. Re: Recalcitrant wildcards

    On Wed, 08 Apr 2009 11:04:10 -0700, Roedy Green wrote:

    > I guess my first job is to figure out who is doing the expansion. I
    > figured I had proof giving it was not happening with a COM asm or C exe
    > command line.
    >

    command.com used to leave glob[1] expansion to the application.

    The Borland C compilers were configurable depending on which command line
    interpreter you selected. The default was to pass globbed names to main()
    without expansion but you could configure the linker to include a wild
    card interpreter that expanded globbed names into argv[] before passing
    it to main().

    I haven't written command line handling code for any MS OS since Win95 so
    I don't know whether cmd.exe works the same way or whether other
    compilers offer the same command line handling choices as the Borland
    ones.

    [1] 'glob' is *NIX slang for the asterisk when it is used in a file name
    and 'file globbing' is slang for the use of wild cards ('*' and '?') in
    file names.


    --
    martin@ | Martin Gregorie
    gregorie. | Essex, UK
    org |
    Martin Gregorie, Apr 9, 2009
    #8
  9. Roedy Green

    Roedy Green Guest

    On Wed, 08 Apr 2009 09:15:43 -0700, Roedy Green
    <> wrote, quoted or indirectly quoted
    someone who said :

    >cert*.html
    >on the command line it gets expanded to:
    >certificate.html certificatevendors.html certification.html
    >
    >I discovered when you pass this wildcard to a DOS *.com program the
    >expansion does not happen.
    >
    >I discovered when you pass this wildcard to a C *.exe program, the
    >expansion does not happen.
    >
    >This suggests Java, not the command processor is doing the expansion.


    I have completed my experiments and I have documented the results at
    http://mindprod.com/jgloss/wildcard.html

    All is reasonably plausible, except that IntelliJ Idea always expands
    wildcards even when enclosed in quotes. I am sending in a bug report.
    --
    Roedy Green Canadian Mind Products
    http://mindprod.com

    "The most significant trend in the US industry has been the decline in the amount
    of energy recovered compared to energy expended. In 1916, the ratio was about 28
    to 1, a very handsome energy return. By 1985, the ratio had dropped to 2 to 1,
    and it is still dropping."
    ~ Walter Youngquist, Professor of Geology

    By 2003, it had dropped to 0.5 to 1 in the US, making oil extraction no longer economically viable, no matter how high the price of crude.
    Roedy Green, Apr 9, 2009
    #9
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Thomas F. O'Connell

    Negative Lookbehind and Wildcards

    Thomas F. O'Connell, Feb 27, 2004, in forum: Perl
    Replies:
    1
    Views:
    716
    Gunnar Hjalmarsson
    Feb 28, 2004
  2. DotNetJunkies User

    DataView filters with wildcards

    DotNetJunkies User, May 24, 2004, in forum: ASP .Net
    Replies:
    0
    Views:
    542
    DotNetJunkies User
    May 24, 2004
  3. msnews.microsoft.com
    Replies:
    0
    Views:
    1,145
    msnews.microsoft.com
    Jul 18, 2004
  4. Josh Martin
    Replies:
    6
    Views:
    1,848
    Josh Martin
    Nov 23, 2003
  5. Dale
    Replies:
    1
    Views:
    1,030
    Wendy S
    Jan 23, 2004
Loading...

Share This Page