Change dir

Purpose: Change current working directory.

 change-dir [ <directory>  | home | run-dir ] [ status <status> ]

change-dir will change current working directory to <directory> (which is a string that can be an absolute or relative path), or to application home directory (see directories) if "home" clause is used.

If "run-dir" clause is used, then current working directory is changed to the directory where you ran the program from. Note that this only applies to command-line programs. If you program runs as a service, then this clause has the same effect as "home" clause.

If "status" clause is used, then number <status> is GG_OKAY if change-dir is successful, or GG_FAILED if not (in which case you can use "errno" clause in get-req to find the specific reason why).

Note that if you change current working directory with call-extended, then you must set Golf internal boolean variable "gg_path_changed" to true.
Examples
 change-dir "/home/user/new_dir" status s
 if-true s equal GG_OKAY
     @Directory changed
 else
     get-req errno to eno
     @Error <<p-num eno>>
 end-if

Use relative path:
 change-dir "./new_dir"

Go back to application home directory:
 change-dir home

See also
Directories
change-dir  
change-mode  
delete-dir  
directories  
new-dir  
See all
documentation


Copyright (c) 2019-2025 Gliim LLC. All contents on this web site is "AS IS" without warranties or guarantees of any kind.