diff options
| -rwxr-xr-x | build | 12 | ||||
| -rwxr-xr-x | include/lib.sh | 9 | ||||
| -rwxr-xr-x | script/roms | 2 | ||||
| -rwxr-xr-x | script/trees | 2 | 
4 files changed, 17 insertions, 8 deletions
| @@ -25,7 +25,7 @@ linkname="${linkpath##*/}"  main()  {  	x_ id -u 1>/dev/null 2>/dev/null -	[ $# -lt 1 ] && $err "Check $projectname documentation for help." +	[ $# -lt 1 ] && badcmd  	spath="script/$1"  	[ "$1" = "dependencies" ] && x_ install_packages $@ && return 0 @@ -43,7 +43,7 @@ main()  	inject) shift 1; vendor_inject $@ ;;  	download) shift 1; vendor_download $@ ;;  	*) -		[ -f "$spath" ] || $err "Bad command. Check docs." +		[ -f "$spath" ] || badcmd  		shift 1; "$spath" $@ || $err "excmd: $spath $@" ;;  	esac  	set -u -e # some commands disable them. turn them on! @@ -51,8 +51,8 @@ main()  install_packages()  { -	[ $# -lt 2 ] && $err "Bad command. Check docs." -	[ -f "config/dependencies/$2" ] || $err "Unsupported target" +	[ $# -lt 2 ] && badcmd "fewer than two arguments" +	[ -f "config/dependencies/$2" ] || badcmd "unsupported target"  	. "config/dependencies/$2" @@ -79,11 +79,11 @@ mkrelease()  	vdir="release"  	while getopts d:m: option; do -		[ -z "$OPTARG" ] && $err "Empty argument not allowed" +		[ -z "$OPTARG" ] && badcmd "empty argument not allowed"  		case "$option" in  		d) vdir="$OPTARG" ;;  		m) mode="$OPTARG" ;; -		*) $err "Invalid option" ;; +		*) badcmd "invalid option '-$option'" ;;  		esac  	done diff --git a/include/lib.sh b/include/lib.sh index 1b0f07c1..8d4b7825 100755 --- a/include/lib.sh +++ b/include/lib.sh @@ -15,6 +15,15 @@ tmpgit="$PWD/tmp/gitclone"  grubdata="config/data/grub"  err="err_" +badcmd() +{ +	errmsg="no context given" +	[ $# -gt 0 ] && errmsg="$1" + +	dstr="Check $projectname docs via $projectsite" +	[ -d "docs" ] && dstr="$dstr (local docs available via docs/)" +	$err "Bad command ($errmsg). $dstr" +}  err_()  {  	printf "ERROR %s: %s\n" "$0" "$1" 1>&2 diff --git a/script/roms b/script/roms index 7e5e1be6..ee48bc42 100755 --- a/script/roms +++ b/script/roms @@ -69,7 +69,7 @@ main()  handle_serprog()  { -	[ -z "${1+x}" ] && $err "bad command. Check $projectname docs." +	[ -z "${1+x}" ] && badcmd  	[ "$1" != "rp2040" ] && [ "$1" != "stm32" ] && $err "bad command"  	if [ "$1" = "rp2040" ]; then  		serprog_boards_dir="$picosdk/src/boards/include/boards" diff --git a/script/trees b/script/trees index 1075b220..e22467f7 100755 --- a/script/trees +++ b/script/trees @@ -27,7 +27,7 @@ main()  		-s) mode="savedefconfig" ;;  		-l) mode="olddefconfig" ;;  		-n) mode="nconfig" ;; -		*) $err "Invalid option" ;; +		*) badcmd "invalid option '-$option'" ;;  		esac  		shift; project="${OPTARG#src/}"; shift  	done | 
