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
pathname
a block special device?- Param pathname:
pathname to test
- Type pathname:
string
- function c? pathname¶
Is
pathname
a character special device?- Param pathname:
pathname to test
- Type pathname:
string
- function d? pathname¶
Is
pathname
a directory?- Param pathname:
pathname to test
- Type pathname:
string
- function e? pathname¶
Does
pathname
exist?- Param pathname:
pathname to test
- Type pathname:
string
- function f? pathname¶
Is
pathname
a regular file?- Param pathname:
pathname to test
- Type pathname:
string
- function l? pathname¶
Is
pathname
a symlink?- Param pathname:
pathname to test
- Type pathname:
string
- function p? pathname¶
Is
pathname
a FIFO?- Param pathname:
pathname to test
- Type pathname:
string
- function r? pathname¶
Does
pathname
satisfylibc/access pathname libc/R_OK
?- Param pathname:
pathname to test
- Type pathname:
string
- function s? pathname¶
Is
pathname
a socket?- Param pathname:
pathname to test
- Type pathname:
string
- function T? fd¶
Is
fd
a terminal?- Param fd:
file descriptor to test
- Type fd:
C/int
- function w? pathname¶
Does
pathname
satisfylibc/access pathname libc/W_OK
?- Param pathname:
pathname to test
- Type pathname:
string
- function x? pathname¶
Does
pathname
satisfylibc/access pathname libc/X_OK
?- Param pathname:
pathname to test
- Type pathname:
string
Last built at 2024-12-21T07:11:04Z+0000 from 463152b (dev)