Skip to content

Commit

Permalink
more posix compliance
Browse files Browse the repository at this point in the history
  • Loading branch information
bit101 committed Nov 12, 2023
1 parent 751bb56 commit 06c2c98
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions version
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ list_tools() {
try_pacman() {
# is pacman installed?
which pacman >/dev/null 2>&1
if [ "$?" -ne 0 ]
if [ "$?" != 0 ]
then
return
fi
Expand All @@ -217,7 +217,7 @@ try_pacman() {

# this will return non-zero if nothing is found
result="$(pacman -Qi $1 2>/dev/null | grep -Ee 'Version')"
if [ "$?" -eq 0 ]
if [ "$?" = 0 ]
then
echo $result | sed -Ene "s/Version : (.*)/$1 version: \1/p"
exit
Expand All @@ -227,7 +227,7 @@ try_pacman() {
try_apt() {
# is apt installed?
which apt >/dev/null 2>&1
if [ "$?" -ne 0 ]
if [ "$?" != 0 ]
then
return
fi
Expand All @@ -236,7 +236,7 @@ try_apt() {
# Let's make sure we're not looking at that instead of the package manager `apt`
# This will fail on Java's `apt`
apt -v >/dev/null 2>&1
if [ "$?" -ne 0 ]
if [ "$?" != 0 ]
then
return
fi
Expand All @@ -255,7 +255,7 @@ try_apt() {
try_dnf() {
# is dnf installed?
which dnf >/dev/null 2>&1
if [ "$?" -ne 0 ]
if [ "$?" != 0 ]
then
return
fi
Expand All @@ -265,7 +265,7 @@ try_dnf() {

# this will return non-zero if nothing is found
result="$(dnf list installed $1 2>/dev/null | grep -Ee $1)"
if [ "$?" -eq 0 ]
if [ "$?" = 0 ]
then
echo $result | sed -Ene "s/[^ ]+ +([^ ]*).*/$1 version: \1/p"
exit
Expand All @@ -275,7 +275,7 @@ try_dnf() {
try_snap() {
# is snap installed?
which snap >/dev/null 2>&1
if [ "$?" -ne 0 ]
if [ "$?" != 0 ]
then
return
fi
Expand All @@ -285,7 +285,7 @@ try_snap() {

# this will return non-zero if nothing is found
result="$(snap list $1 2>/dev/null | grep -Ee $1)"
if [ "$?" -eq 0 ]
if [ "$?" = 0 ]
then
echo $result | sed -Ene "s/^$1 +([^ ]*).*/$1 version: \1/p"
exit
Expand All @@ -295,7 +295,7 @@ try_snap() {
try_flatpak() {
# is flatpak installed?
which flatpak >/dev/null 2>&1
if [ "$?" -ne 0 ]
if [ "$?" != 0 ]
then
return
fi
Expand All @@ -319,7 +319,7 @@ try_flatpak() {
try_npm() {
# is npm installed?
which npm >/dev/null 2>&1
if [ "$?" -ne 0 ]
if [ "$?" != 0 ]
then
return
fi
Expand All @@ -329,7 +329,7 @@ try_npm() {

# this will return non-zero if nothing is found
result="$(npm list --global --depth 0 $1 2>/dev/null | grep -m 1 -Ee $1)"
if [ "$?" -eq 0 ]
if [ "$?" = 0 ]
then
echo $result | sed -Ene "s/.*$1@(.*)/$1 version: \1/p"
exit
Expand All @@ -339,7 +339,7 @@ try_npm() {
try_pip() {
# is pip installed?
which pip >/dev/null 2>&1
if [ "$?" -ne 0 ]
if [ "$?" != 0 ]
then
return
fi
Expand All @@ -360,7 +360,7 @@ try_pip() {
try_brew() {
# is brew installed?
which brew >/dev/null 2>&1
if [ "$?" -ne 0 ]
if [ "$?" != 0 ]
then
return
fi
Expand Down

0 comments on commit 06c2c98

Please sign in to comment.