pashmak

OS Module

This module gives some APIs for operation system related actions.

os.chdir

This function changes the program current working directory.

import @os

os.chdir('/path/to/new/directory')

os.mkdir

This function makes a directory.

os.mkdir('/path/to/new/directory')

os.cpu_count

This function returns CPU count.

println(os.cpu_count())

$os.curdir

Will return the current directory that you are working in

println($curdir)

os.kill

Will kill a process.

os.kill($process_id, $signal)

os.rmdir

Will remove a directory.

os.rmdir("directory-name")

$os.osname

will return os name.

println($os.osname)

os.isdir

Will return does a directory exists or not.

os.isdir("dir-name")

os.isfile

Will return a file exists or not.

os.isfile("file-name")

os.exists

Will return some file/dir exists or not.

os.exists("somethingfileordir")

$os.env

This variable is a dictonary contains process environment variables.

For example:

import @os

println($os.env['TEST_VAR'])

Then we run this:

$ TEST_VAR=hello pashmak myfile.pashm

output:

hello

os.cwd

This function returns program current working directory.

println(os.cwd())