diff options
author | Tom Ryder <tom@sanctum.geek.nz> | 2016-08-09 17:15:40 +1200 |
---|---|---|
committer | Tom Ryder <tom@sanctum.geek.nz> | 2016-08-09 17:20:10 +1200 |
commit | 9fb350dc7c8cc5259ef24e0cb097031179fab1d6 (patch) | |
tree | 839dd0b8ee3f5323b1cd6aefa22b605b99437d62 /bin/rndf | |
parent | Mention nosls/sls flags in slsf(1) man page (diff) | |
download | dotfiles-9fb350dc7c8cc5259ef24e0cb097031179fab1d6.tar.gz dotfiles-9fb350dc7c8cc5259ef24e0cb097031179fab1d6.zip |
Improve commenting/exit handling in binscripts
Diffstat (limited to 'bin/rndf')
-rwxr-xr-x | bin/rndf | 10 |
1 files changed, 9 insertions, 1 deletions
@@ -1,9 +1,17 @@ #!/bin/sh -# Choose a random file from a given directory using rnda(1). Ignores dot files. +# Choose a random file from a given directory using rnda(1); ignores dot files + +# Directory is first argument; defaults to current directory dir=${1:-.} + +# Set the positional parameters to all the non-dotfiles in that directory set -- "$dir"/* + +# Check for an unexpanded glob (empty directory) if ! [ -e "$1" ] ; then printf >&2 'rndf: No files found in %s\n' "$dir" exit 1 fi + +# Print a random argument from the current positional parameters rnda "$@" |