diff --git a/README.md b/README.md index 6369be4..dbf687c 100644 --- a/README.md +++ b/README.md @@ -23,7 +23,10 @@ etools_unset etools_smart_find [repo] # repo can be a path relative to /var/db/repos/ or a full path # default will be /var/db/repos/ so all repos will be searched -# btw feel free to time it ;) +eools_get_version [offset] +# offset will output the latest version +# eg.: when 1.2.3 is latest offset 1 will result in a version 1 beneath 1.2.2-r2 for example +# btw feel free to time both of them ;) ``` ## Configuration @@ -71,4 +74,3 @@ done <<< $( done ); ``` - diff --git a/etools b/etools index 10fee50..b784ae9 100644 --- a/etools +++ b/etools @@ -57,7 +57,7 @@ function etools_get_version() { [ "$ETOOLS_CHECK_LIVE" ] && if _matches_live "$1"; then # use ls over find for simplicity # shellcheck disable=SC2012 - latest="$(ls -1vr "${ETOOLS_REPO_PATH:-/var/db/repos}"/*/"$1"/*9999*.ebuild | head "-${2:-1}" 2>/dev/null)" + latest="$(ls -1vr "${ETOOLS_REPO_PATH:-/var/db/repos}"/*/"$1"/*9999*.ebuild | head -1 2>/dev/null)" [ -n "$latest" ] && _extract_version "$latest" && ./helper.sh && return 0; fi if [ "$ETOOLS_CHECK_TESTING" ]; then @@ -68,14 +68,14 @@ function etools_get_version() { arch="amd64" fi if [[ "$ACCEPT_KEYWORDS" == *"~$arch"* ]] || _matches_testing "$1" "\~$arch"; then - latest=$(_get_latest "$1" "${package_offset[$1]:-0}" "~$arch") + latest=$(_get_latest "$1" "${2:-${package_offset[$1]:-0}}" "~$arch") fi [ -n "$latest" ] && _extract_version "$latest" && ./helper.sh && return 0; fi - _get_latest "$1" "${package_offset[$1]:-0}" "$arch" + _get_latest "$1" "${2:-${package_offset[$1]:-0}}" "$arch" [ -n "$latest" ] && _extract_version "$latest" && ./helper.sh && return 0; - ewarn "No version found for package: $1$( (( ! ${package_offset[$1]:-0} == 0 )) && echo " with offset $offset")" + ewarn "No version found for package: $1$( (( ! ${2:-${package_offset[$1]:-0}} == 0 )) && echo " with offset $offset")" } diff --git a/helper.sh b/helper.sh index 4bf040a..d8f70bd 100755 --- a/helper.sh +++ b/helper.sh @@ -200,7 +200,7 @@ function _get_latest() { fi fi done - (( ! offset < 0 )) && ewarn "Unused offset of: $offset" + (( offset >= 0 )) && ewarn "Unused offset of: $(( offset + 1 )), from specified offset of: $2" "\n" echo "$latest" }