# # $SRC_Id: README.tmpl,v 1.8 2014/11/21 14:34:50 craski-shell_86 Exp $ # # # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- # Function # ======== # shell script system exit codes library # # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- # Description # =========== # libsysexits provides a shell script compatible reformatted version of the established C system exits header file from OpenBSD: /usr/src/include/sysexits.h # # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- # Usage # ===== # $OpenBSD$ +------------------------------------------------------------------------------- | Running libsysexits-1.8.7 on OpenBSD +------------------------------------------------------------------------------- # # Example library usage by shell scripts: # # --------8<--------- #!/bin/ksh # source the exit codes if not already exported into the environment: . /usr/local/lib/sysexits.sh hf='/etc/hosts' [[ -f ${hf} ]] || { print -u2 "${hf} is not a file" exit ${EX_OSFILE} } [[ -w ${hf} ]] || { print -u2 "${hf} not writeable by ${LOGNAME}" exit ${EX_NOPERM} } thf=$(mktemp) || exit ${EX_TEMPFAIL} # More clever scripting... # -------->8--------- # # Other examples: # # --------8<--------- mkdir ${lock} 2>/dev/null || exit ${EX_TEMPFAIL} /etc/rc.d/dhcpd check || alert ${EX_UNAVAILABLE} "dhcpd isn't running" cd ${cache} || finish ${EX_IOERR} "Can't cd into ${cache}" # -------->8--------- # # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- # Source code access # ================== # # # HTTP download: # http://web.britvault.co.uk/products/libsysexits/libsysexits-1.8.7.tar.gz # # Anonymous CVS checkout: # # *** NOTE: Neither password nor network encryption is needed. # you$ cd $(mktemp -d) you$ export CVSROOT=':pserver:anoncvs@src.britvault.co.uk:/var/spool/cvs' you$ cvs -q checkout -P libsysexits # # Edit files and test as per the above section. # When done, generate a diff of your work, then # send it with your comments to the mailing list below: # you$ cvs -q diff -uNp libsysexits/ | tee libsysexits.$$.diff # # Mailing list for discussion & diffs/patches: # post: libsysexits@britvault.co.uk join: libsysexits+subscribe@britvault.co.uk leave: libsysexits+unsubscribe@britvault.co.uk # # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- # Building # ======== # The library file 'sysexits.sh' is included in the tarball/CVS repository. # # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- # Installing # ========== # The built library could be installed in /usr/local/lib you$ sudo install -b -p -S -o root -g bin -m 0444 sysexits.sh /usr/local/lib you$ ls -lo /usr/local/lib/sysexits.sh -r--r--r-- 1 root bin - 8136 Nov 20 16:24 /usr/local/lib/sysexits.sh # # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- #