Changing Directory¶
Idio supports a very simplistic set of directory changing functions revolving around a directory stack.
The shell-like cd
(with no arguments) cannot be directly
implemented in Idio (because it’s a programming language and
cd
returns the value of the function cd) so you are
required to wrap it in parenthesis, which uses HOME
, or pass
~
which is a synonym for HOME
.
Note
These functions work with respect to PWD in the sense that relative directory movements modify PWD and then libc/chdir is called on PWD.
For example, on this system /sbin
is a symlink to
/usr/sbin
:
Idio> cd "/sbin"
0
Idio> (libc/getcwd)
%P"/usr/sbin"
Idio> cd ".."
0
Idio> (libc/getcwd)
%P"/"
Notice that the cd ".."
returns us to /
and not
/usr
, the parent of the directory we were actually in.
An absolute directory movement simply sets PWD (and calls libc/chdir).
- template cd [dir]¶
change the current working directory to dir
- Param dir:
the directory to change to, defaults to
HOME
- Type dir:
string
- Return:
current working directory or
#f
If dir does not exist a message is displayed and
#f
is returned.If dir is not supplied or is the symbol
~
,HOME
is used.This function modifies PWD.
See also
cd
calls setd.
- function pushd d¶
if d is a directory then change the working directory to it and push it onto the top of the directory stack.
- Param d:
directory to change to
- Type d:
string
- Return:
current working directory or
#f
This function modifies PWD.
- function popd¶
if the directory stack has more than one entry then pop an element off the directory stack and change the working directory to the top-most element
- Return:
current working directory or
#f
This function modifies PWD.
- function dirs¶
print the directory stack
- function setd d¶
if d is a directory then change the working directory to it and set the top entry in the directory stack to it.
- Param d:
directory to change to
- Type d:
string
- Return:
current working directory or
#f
This function modifies PWD.
Last built at 2024-12-21T07:10:38Z+0000 from 62cca4c (dev) for Idio 0.3.b.6