plugins/base: `mkiso()`

Expressly handle unbound parameters.
pull/1930/head
John D Pell 2021-09-23 22:55:09 -07:00
parent 8d3e81a49f
commit 96239a286a
1 changed files with 5 additions and 6 deletions

View File

@ -149,9 +149,8 @@ function command_exists ()
type -t "$1" >/dev/null type -t "$1" >/dev/null
} }
if type -t mkisofs >/dev/null; then if _command_exists mkisofs; then
function mkiso() function mkiso() {
{
about 'creates iso from current dir in the parent dir (unless defined)' about 'creates iso from current dir in the parent dir (unless defined)'
param '1: ISO name' param '1: ISO name'
param '2: dest/path' param '2: dest/path'
@ -164,11 +163,11 @@ function mkiso()
local destpath="${2:-../}" local destpath="${2:-../}"
local srcpath="${3:-${PWD}}" local srcpath="${3:-${PWD}}"
if [ ! -f "${destpath}${isoname}.iso" ]; then if [[ ! -f "${destpath%/}/${isoname}.iso" ]]; then
echo "writing ${isoname}.iso to ${destpath} from ${srcpath}" echo "writing ${isoname}.iso to ${destpath} from ${srcpath}"
mkisofs -V "${isoname}" -iso-level 3 -r -o "${destpath}${isoname}.iso" "${srcpath}" mkisofs -V "${isoname}" -iso-level 3 -r -o "${destpath%/}/${isoname}.iso" "${srcpath}"
else else
echo "${destpath}${isoname}.iso already exists" echo "${destpath%/}/${isoname}.iso already exists"
fi fi
} }
fi fi