Jump to content




Is there an equivalent for $PATH in CraftOs?


  • You cannot reply to this topic
6 replies to this topic

#1 lincore

  • Members
  • 11 posts

Posted 12 December 2012 - 11:28 PM

So I got into cc recently and I'm having a blast so far, but I'm wondering: Is there a way to execute programs without either traversing the directory tree or specifying the path?
Ideally I'd like to have a list of directories that the shell checks for an executable by the given name.

#2 CoolisTheName007

  • Members
  • 304 posts

Posted 13 December 2012 - 12:25 AM

I could adapt loadreq to that; in fact I'm gonna do it.

#3 CoolisTheName007

  • Members
  • 304 posts

Posted 13 December 2012 - 01:12 AM

Ok, updated the loadreq with a simple function and some changes that allow to use it to run files as normally.
E.g.:
---runs filepath path with args ... using the same rules as @require for determining the globs to uses
--e.g.
--[[
os.loadAPI('APIS/loadreq')
loadreq.vars.paths=loadreq.vars.paths..';myFolder'
--or
REQUIRE_PATH='myFolder'
--ect
loadreq.run_lua('subFolder/subsubFolder/myFile.lua',arg1,arg2,...)
]]


#4 KaoS

    Diabolical Coder

  • Members
  • 1,510 posts
  • LocationThat dark shadow under your bed...

Posted 13 December 2012 - 02:30 AM

use the command shell.setPath(dirs separated by ';'s ) it is the equivalent of %path% in cmd

local function add(dir)
  if fs.exists(dir) and fs.iDir(dir) then
	shell.setPath(shell.getPath..';'..shell.resolve(dir))
  end
end


#5 CoolisTheName007

  • Members
  • 304 posts

Posted 13 December 2012 - 05:39 AM

View PostKaoS, on 13 December 2012 - 02:30 AM, said:

snip

How dumb of me to misinterpret the whole thing.. :blink:

#6 KaoS

    Diabolical Coder

  • Members
  • 1,510 posts
  • LocationThat dark shadow under your bed...

Posted 13 December 2012 - 06:44 AM

View PostCoolisTheName007, on 13 December 2012 - 05:39 AM, said:

snip

we all derp. chilled stuff

#7 lincore

  • Members
  • 11 posts

Posted 14 December 2012 - 10:35 PM

View PostKaoS, on 13 December 2012 - 02:30 AM, said:

use the command shell.setPath(dirs separated by ';'s ) it is the equivalent of %path% in cmd

local function add(dir)
  if fs.exists(dir) and fs.iDir(dir) then
	shell.setPath(shell.getPath..';'..shell.resolve(dir))
  end
end
Just what I was looking for, thank you!

View PostCoolisTheName007, on 13 December 2012 - 05:39 AM, said:

[...]
How dumb of me to misinterpret the whole thing.. :blink:
After all we're only humans == derpy :~)
Thanks for trying to help me out.





2 user(s) are reading this topic

0 members, 2 guests, 0 anonymous users