Skip to content

Commit

Permalink
Create a Bash script as a wrapper for port info
Browse files Browse the repository at this point in the history
The script fetches some online information.
  • Loading branch information
FranklinYu committed Jul 24, 2021
1 parent f8a0ea1 commit 1d040ab
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
1 change: 1 addition & 0 deletions .deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ ensure_link ~/.config/zsh/profile.zsh ~/.zprofile

mkdir -p ~/.local/bin
ensure_link ~/.config/.executables/ping-me ~/.local/bin/ping-me
ensure_link ~/.config/.executables/port-info ~/.local/bin/port-info

mkdir -p ~/.cache
cd ~/.cache
Expand Down
24 changes: 24 additions & 0 deletions .executables/port-info
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/bin/bash

set -o nounset -o pipefail

function print-field() {
# No idea why MacPorts chose 21 as width
printf '%-21s %s\n' "$1:" "$2"
}

port info "$@"
return_value=$?
if (( return_value == 0 )) && (( $# == 1 )) && [[ `port file "$1"` == */rsync.macports.org/* ]]
then
print-field 'Port URL' "https://ports.macports.org/port/$1/details/"
if command -v curl >/dev/null
then
package_url="https://packages.macports.org/$1/"
if curl --head --fail --silent "$package_url" >/dev/null
then print-field 'Binary Package' "$package_url"
else print-field 'Binary Package' no
fi
fi
fi
exit $return_value

0 comments on commit 1d040ab

Please sign in to comment.