#!/bin/bash request=$1 shift commands=(info help version ffmpeg) commands+=(cmd_*) cd /assets . SOLUTION . MANIFEST name() { cat << EOF Intel Accelerated Graphics and Media Access container Copyright (C) 2019 Intel Corporation ----- EOF } info() { [ "$1" == "--short" ] && { echo "Information about running container environment" } || { cat << EOF $(name) Detected base OS: Ubuntu 19.04 Detected hardware: None Detected Agama version: ${AGAMA_VERSION} EOF } } version() { [ "$1" == "--short" ] && { echo "Show container version information" } || { cat << EOF $CONTAINER built using Agama $AGAMA_VERSION. EOF } } ffmpeg() { [ "$1" == "--short" ] && { echo "Run ffmpeg commands." } || { /usr/local/bin/ffmpeg $* } } help() { [ "$1" == "--short" ] && { echo "This help information" } || { cat << EOF $(name) Commands: EOF # Change cmd_foo to ./cmd_foo in expansion below for cmd in ${commands[@]}; do printf " %-15s %s\n" ${cmd/cmd_} "$(${cmd/cmd_/./cmd_} --short)" done } } case $request in info) info $* ;; ffmpeg) ffmpeg $* ;; version) version $* ;; help|"") help $* ;; *) [ ! -f ./cmd_$request ] && { echo "'${request}' is not a recognized command." } || { ./cmd_$request $* } ;; esac