Shell Functions¶
There are plenty of shell functions it would convenient to retain.
Predicates¶
Bash offers a number of predicates which we can re-imagine
and maybe (maybe not!) avoid some legacy. In particular,
Bash uses upper-case -S to test if a file is a socket
whereas all the other file predicates are in lower-case. In addition,
rather than -h or -L for testing for a symbolic link we can
use l?.
We can now use upper-case predicates for other objects, notably, file
descriptors, eg. T? for terminals.
- function b? pathname¶
Is
pathnamea block special device?- Param pathname:
pathname to test
- Type pathname:
string
- function c? pathname¶
Is
pathnamea character special device?- Param pathname:
pathname to test
- Type pathname:
string
- function d? pathname¶
Is
pathnamea directory?- Param pathname:
pathname to test
- Type pathname:
string
- function e? pathname¶
Does
pathnameexist?- Param pathname:
pathname to test
- Type pathname:
string
- function f? pathname¶
Is
pathnamea regular file?- Param pathname:
pathname to test
- Type pathname:
string
- function l? pathname¶
Is
pathnamea symlink?- Param pathname:
pathname to test
- Type pathname:
string
- function p? pathname¶
Is
pathnamea FIFO?- Param pathname:
pathname to test
- Type pathname:
string
- function r? pathname¶
Does
pathnamesatisfylibc/access pathname libc/R_OK?- Param pathname:
pathname to test
- Type pathname:
string
- function s? pathname¶
Is
pathnamea socket?- Param pathname:
pathname to test
- Type pathname:
string
- function T? fd¶
Is
fda terminal?- Param fd:
file descriptor to test
- Type fd:
C/int
- function w? pathname¶
Does
pathnamesatisfylibc/access pathname libc/W_OK?- Param pathname:
pathname to test
- Type pathname:
string
- function x? pathname¶
Does
pathnamesatisfylibc/access pathname libc/X_OK?- Param pathname:
pathname to test
- Type pathname:
string
Last built at 2025-10-28T07:10:59Z+0000 from 463152b (dev)