Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > Recallcitrant wildcards

Reply
Thread Tools

Recallcitrant wildcards

 
 
Roedy Green
Guest
Posts: n/a
 
      04-08-2009
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
 
Reply With Quote
 
 
 
 
Mark Space
Guest
Posts: n/a
 
      04-08-2009
Roedy Green wrote:

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



SSCCE?



 
Reply With Quote
 
 
 
 
Chris Riesbeck
Guest
Posts: n/a
 
      04-08-2009
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

 
Reply With Quote
 
Mark Space
Guest
Posts: n/a
 
      04-08-2009
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?

 
Reply With Quote
 
Roedy Green
Guest
Posts: n/a
 
      04-08-2009
On Wed, 08 Apr 2009 09:58:16 -0700, Mark Space
<(E-Mail Removed)> 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
 
Reply With Quote
 
Roedy Green
Guest
Posts: n/a
 
      04-08-2009
On Wed, 08 Apr 2009 10:46:44 -0700, Mark Space
<(E-Mail Removed)> 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
 
Reply With Quote
 
Lew
Guest
Posts: n/a
 
      04-08-2009
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
 
Reply With Quote
 
Martin Gregorie
Guest
Posts: n/a
 
      04-08-2009
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 |
 
Reply With Quote
 
Roedy Green
Guest
Posts: n/a
 
      04-09-2009
On Wed, 08 Apr 2009 09:15:43 -0700, Roedy Green
<(E-Mail Removed)> 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.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
wildcards ? Martin Bilgrav Cisco 2 09-05-2005 06:24 PM
File names for monitoring must have absolute paths, and no wildcards. msnews.microsoft.com ASP .Net 0 07-18-2004 08:41 PM
DataView filters with wildcards DotNetJunkies User ASP .Net 0 05-24-2004 09:25 PM
Negative Lookbehind and Wildcards Thomas F. O'Connell Perl 1 02-28-2004 01:50 PM
Struts: Using Wildcards in ActionMapping Josh Martin Java 6 11-23-2003 06:06 PM



Advertisments