Recallcitrant wildcards

R

Roedy Green

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
 
C

Chris Riesbeck

Roedy said:
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
 
M

Mark Space

Chris said:
Roedy said:
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?
 
R

Roedy Green

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
 
R

Roedy Green

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
 
L

Lew

Mark said:
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.
 
M

Martin Gregorie

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

Roedy Green

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.
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,756
Messages
2,569,535
Members
45,008
Latest member
obedient dusk

Latest Threads

Top