lib: Add get-component-name/type-from-path

pull/1628/head
Noah Gorny 2020-06-27 15:28:47 +03:00 committed by Noah Gorny
parent 811c9ecd71
commit 8d9f81fce0
1 changed files with 18 additions and 0 deletions

View File

@ -6,6 +6,24 @@
# Generic utilies
###########################################################################
_bash-it-get-component-name-from-path() {
# filename without path
filename=${1##*/}
# filename without path or priority
filename=${filename##*---}
# filename without path, priority or extension
echo ${filename%.*.bash}
}
_bash-it-get-component-type-from-path() {
# filename without path
filename=${1##*/}
# filename without path or priority
filename=${filename##*---}
# extension
echo ${filename} | cut -d '.' -f 2
}
# This function searches an array for an exact match against the term passed
# as the first argument to the function. This function exits as soon as
# a match is found.