New and having problems

new topic     » topic index » view thread      » older message » newer message

So I decided Euphoria was something worth checking out and wanted to port a small project over from ruby. Needless to say I have been having problems which I am sure is part of being new to the language and my own terrible logic when it comes to working things out.

So the program is supposed to be simple: a program that can take multiple command line arguments and pass them to my package manager. The goal is to make a basic package manager wrapper and so far I have had more problems doing it in Euphoria than in Ruby due to all the difference in syntax. I am just not used to the Euphoria ways of doing things quite yet.

Here is the code with which I am having problems. All this code is supposed to do is take command line arguments and pass them to a variable which is then passed to the system(). The problem is that when I run my program (e.g myprog -i gimp firefox) only the second argument after -i is being read but if I take away the second argument, then gimp in the example will be read.

The goal is to have everything read and passed to the package manager. One big long string of words!

include std/io.e 
include std/console.e 
include std/os.e 
include std/cmdline.e 
 
 
global sequence cmd = command_line() 
global sequence pkgargs 
 
 
 
for i = 4 to length(cmd) do --start at 4 to skip the first few arguments 
    
   pkgargs = cmd[i] 
    
     
end for 
 
 
switch cmd[3] do --start at 3 to capture -i 
  case "-i" then 
   
    printf(1,"%s\n",pkgargs) --a debug line to print pkgargs 
     
    system ("sudo xbps-install " & pkgargs,2) --simply passing pkgargs to system 
     
end switch 

The debug line only prints out the first character of the word it was given. So if I typed 'gimp' it would print 'g'. I thought it would print the full word or the full list of arguments in pkgargs but I was wrong and I don't know why this is happening.

Overall though I have the feeling that I am doing something very wrong that is simple to fix but instead of spending the next several days tearing my hair out I decided to ask for help.

Thanks for helping, I am glad to be here.

new topic     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu