Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

asterisk in command line parameter converted to something else  RSS feed

 
Eric Daly
Ranch Hand
Posts: 143
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am writing a program to take 3 command line parameters and perform simple arithmetic. The second parameter is either +, -, *, /, or %. They all work fine except for the asterisk. So if my command line parameters are 6 * 5, when I display all the arguments, it says I have 4 arguments:
args[0]: 6
args[1]: Calculator.class
args[2]: MathWorker.class
args[3]: 5

I am using those two classes... how can i tell my program to just accept an asterisk as an asterisk without it being converted into a list of the classes I'm using? Thanks.
 
Paul Clapham
Sheriff
Posts: 22480
43
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Your shell automatically expands * to be a list of files in the current directory. How you do that depends on what shell you are using. Since you didn't know this I will guess that it is the Windows command prompt. Try typing these two lines at the command line:
dir *
dir '*'
and you will see what I mean.
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Use double quotations around the asterix
 
Eric Daly
Ranch Hand
Posts: 143
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, I am using the Windows XP command prompt. So there is not a way to disable the automatic "globbing" (I heard it referred to) that the command prompt promptly commands itself to do? Thanks for the help.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!